home *** CD-ROM | disk | FTP | other *** search
- #pragma segment NewTel /* NCSA 2.5 */
- /*#define NEW_STUFF 1 /* BYU - changed to "MacTCPdriver" for use in Make file. */
- #ifdef lint
- static char *SCCSid = "%W% (NCSA) %G%";
- #endif
- /*
- * menu.c
- * by Gaige B. Paulsen
- ****************************************************************************
- * Part of NCSA Telnet for the Macintosh *
- * *
- * Uses : *
- * TCP/IP kernel for NCSA Telnet *
- * by Tim Krauskopf *
- * with Macintosh code by Gaige B. Paulsen *
- * *
- * National Center for Supercomputing Applications *
- * 152 Computing Applications Building *
- * 605 E. Springfield Ave. *
- * Champaign, IL 61820 *
- * *
- * *
- ****************************************************************************
- *
- * Menu Handling and initialization code.
- *
- * Called by:
- * event.c
- * maclook.c
- */
-
- /*
- * Files to be included in the compile
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
-
- #include <Desk.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Fonts.h>
- #include <Lists.h> /* NCSA */
- #include <Memory.h>
- #include <Menus.h>
- #include <OsUtils.h>
- #include <Packages.h>
- #include <Printing.h>
- #include <Quickdraw.h>
- #include <Resources.h> /* BYU 2.4.12 */
- #include <Scrap.h>
- #include <ToolUtils.h>
- #include <Strings.h>
-
- #include "alias.h" /* NCSA: alias definitions */
- #include "protocol.h"
- #include "wind.h"
- #include "configrec.h"
-
- #include "hostform.h"
- #include "prefs.h"
- #include "netevent.h"
- #include "dlayer.h"
- #include "util.h"
- #include "rsmac.h"
- #include "user.h"
- #include "maclook.h"
- #include "macutil.h"
- #include "vrrgmac.h"
- #include "rgmp.h"
- #include "tekrgmac.h"
- #include "vgtek.h"
- #include "vsinterf.h"
- #include "event.h"
- #include "config.h"
- #include "mactools.h"
- #include "confile.h"
- #include <MacTCPCommonTypes.h>
- #include <AddressXlation.h>
- #include "ser.h" /* BYU 2.4.15 */
- #include "slip.h" /* BYU 2.4.15 */
- /*#include "dnr.c" /* BYU 2.4.15 */
-
- #ifdef MPW
- #include "mpw.h"
- #endif MPW
-
- /*
- * Resource Defines
- */
-
- /*----------------------------------------------------------------*/
- /* NCSA: these are the new defines for the alias code */
-
- #define kListMods 0
-
- #define AliasDLOG 130
- #define kAliasOutline 12
- #define kAliasHostItem 9
- #define kAliasPortItem 10
- #define kAliasAliasItem 11
- #define kAliasRemove 4
- #define kAliasCancel 2
- #define kAliasOK 1
- #define kAliasAdd 3
- #define kAliasList 13
- /*-----------------------------------------------------------------*/
-
- #define DLOGOk 1
- #define DLOGCancel 2
-
- #define MacroDLOG 500 /* The Macros dialog */
- #define QuitDLOG 2010 /* The Quit Confirmation Dialog */
- #define CloseDLOG 2001 /* The Close Confirmation Dialog */
-
- #define SessionDLOG 257 /* The Session initialization dialog ----------- */
- #define Shost 5 /* The Destination field in GetDest dialog */
- #define Sname 7 /* Session name in session dialog */
- #define Sftponly 9 /* BYU - Indicates an FTP only session */
- #define Sserialonly 10 /* BYU 2.4.15 - Indicates a serial port session */
-
- #define SConfigDLOG 260 /* The Session configuration dialog ------------ */
- #define SChost 4 /* Put the session name here [STATIC] */
- #define SCname 6 /* Session name in session dialog */
- #define SCwidth132 8 /* Session width is 132 */
- #define SCwidth80 9 /* Session width is 80 */
- #define SCkbbs 11 /* Keyboard Backspace default */
- #define SCkbdel 12 /* Keyboard Delete default */
- #define SCscrolon 13 /* Session scrollback toggle */
- #define SCscrolnum 14 /* Session scrollback number of lines */
- #define SCtekclear 17 /* Session Tek <esc> ^L clears screen */
- #define SCtekcreate 18 /* Session Tek <esc> ^L creates new window */
- #define SCcrLF 20 /* Session cr translates to <cr><lf> */
- #define SCcrNUL 21 /* Session cr translates to <cr><nul> */
- #define SCechoBuff 23 /* Session echo mode buffers (local edit ) */
- #define SCechoSend 24 /* Session echo mode sends (half duplex ) */
- #define SCtekold 27 /* TEK 4014 emulation */
- #define SCteknew 28 /* TEK 4105 emulation */
- #define SClineY 30 /* Line mode on */ /* BYU 2.4.9 */
- #define SClineN 31 /* Line mode off */ /* BYU 2.4.9 */
- #define SCeightY 33 /* Eight bits of font displayed */ /* BYU 2.4.9 */
- #define SCeightN 34 /* Seven bits of font displayed */ /* BYU 2.4.9 */
- #define SCtekdis 35 /* NCSA 2.5: disabe TEK entirely */
-
- #define LinesDLOG 272 /* The number of lines config dialog ----------- */
- #define LinesNumber 5 /* User given # of lines */
-
- #define SetupDLOG 273 /* Setup keys interface */
-
- #define StatusDLOG 270 /* Inactive connection status dialog */
- #define BadDynDLOG 280 /* Bad Dynamic IP Number search */
-
- #define PGRECT (*prRecHdl)->prInfo.rPage /* Macro for making the pagerect more accessible */
-
-
- /*
- * Defines for the menu handling code.
- */
-
- #define appleMenu 1 /* Apple Menu ID */
- #define NfileMenu 512 /* File Menu Resource ID */
- #define NeditMenu 513 /* Edit Menu Resource ID */
- #define NtermMenu 514 /* Emulation Menu Resource ID */
- #define NconnMenu 515 /* Connection Menu Resource ID */
- #define NnetMenu 516 /* Network Menu Resource ID */
-
- #define fileMenu 256 /* File Menu ID */
- #define editMenu 257 /* Edit Menu ID */
- #define termMenu 258 /* Emulation Menu ID */
- #define connMenu 259 /* Connection Menu ID */
- #define netMenu 260 /* Network Menu Resource ID */
- #define fontMenu 128 /* Font Menu Resource ID */
- #define sizeMenu 129 /* Size Menu Resource ID */
-
- #define Fil 1 /* File Menu's Position */
- #define Edit 2 /* Edit Menu's Position */
- #define Emul 3 /* Emulation Menu's position */
- #define Net 4 /* Network Menu's position */
- #define Conn 5 /* Connection Menu's position */
- #define Font 6 /* Font Menu's position */
- #define Size 7 /* Size Menu's position */
-
- /* ----------------- The File Menu ---------------------- */
- #define FLopen 1 /* File Menu: Open Connection */
- #define FLclose 2 /* File Menu: Close Connection */
- #define FLload 4 /* File Menu: Load Set */
- #define FLsave 5 /* File Menu: Save Set */
- #define FLftp 7 /* File Menu: ftp on */
- #define FLbin 8 /* File Menu: MacBinary on */
- #define FLlog 9 /* File Menu: ftp log on */
- #define FLdir 10 /* File Menu: Set Transfer Directory */
- #define FLprint 12 /* File Menu: Print Selection */
- #define FLpset 13 /* File Menu: Page Setup */
- #define FLquit 15 /* File Menu: Quit */
- #define FLsession 16 /* ftp session */
-
- /* ----------------- The Edit Menu ---------------------- */
- #define EDundo 1
- #define EDcut 3
- #define EDcopy 4 /* Edit Menu: Copy */
- #define EDpaste 5 /* Edit Menu: Paste */
- #define EDclear 6 /* Edit Menu: Clear */
- #define EDcopyt 7 /* Edit Menu: Copy Table */
- #define EDmacros 9 /* Edit Menu: Macros */
- #define EDprefs 10 /* Edit Menu: Preferences */
-
- /* ----------------- The Session Menu ---------------------- */
- #define EMbs 1 /* Emulation Menu: backspace */
- #define EMdel 2 /* Emulation Menu: delete */
- #define EMecho 4 /* Emulation Menu: echo */
- #define EMwrap 5 /* Emulation Menu: Wrap mode on/off */
- #define EMscroll 6 /* Emulation Menu: Clear Screen Saves Lines */
- #define EMreset 7 /* Emulation Menu: Reset Terminal */
- #define EMjump 8 /* Emulation Menu: Jump Scroll */
- #define EMpage 9 /* Emulation Menu: TEK Page command */
- #define EMclear 10 /* BYU 2.4.8 - Emulation Menu: TEK Page clears screen */
- #define EMlines 12 /* Emulation Menu: Set Usable Lines */
- #define EMsetup 13 /* Emulation Menu: Setup keys */
- #define EMfont 14 /* Emulation Menu: Font */
- #define EMsize 15 /* Emulation Menu: Size */
- #define EMcolor 16 /* Emulation Menu: Color */
- #define EMslip 18 /* BYU 2.4.15 - Emulation Menu: Switch to SLIP */
- #define EMserial 19 /* BYU 2.4.15 - Emulation Menu: Switch to Serial */
- #define EMcapture 21 /* BYU 2.4.18 - Emulation Menu: Capture to file */
-
- /* ----------------- The Network Menu ---------------------- */
- /* #define NEcommand 19 Emulation Menu: Command Keys */
- #define NEftp 1 /* Emulation Menu: Send ftp command */
- #define NEip 2 /* Emulation Menu: Send IP # */
- #define NEayt 4 /* Emulation Menu: Send "Are You There" */
- #define NEao 5 /* Emulation Menu: Send "Abort Output" */
- #define NEinter 6 /* Emulation Menu: Send "Interrupt Process" */
- #define NEec 7 /* Emulation Menu: Send "Erase Character" */
- #define NEel 8 /* Emulation Menu: Send "Erase Line" */
- #define NEscroll 10 /* Network Menu: Scroll Lock */
- #define NEnet 12 /* Network Menu: Show Net #'s */
- #define NEconfig 13 /* Network Menu: Configure Network */
- #define NEserial 14 /* Network Menu: Serial Port Settings */ /* BYU serial */
- #define NEalias 15 /* NCSA: alias menu item */
-
-
- #define YESFTP 1
- #define NOFTP 0
-
- #define NMENUS 8 /* We have NMENUS menus right now */
-
- #define COnext 1 /* Connection Menu: Next Session... */
- #define CR 0x0d /* the carriage return character */
- #define BS 0x08 /* the backspace character */
- #define TAB 9
-
- /*
- * Internal Variable declarations
- */
-
- short
- modalItems, /* BYU 2.4.15 */
- modalItem[3] = {0,0}, /* BYU 2.4.15 - Item no. for modal cmd key feature */
- modalKey[3], /* BYU 2.4.15 - Key code for modal cmd key feature */
- *FontNumber = 0L; /* Array of Font Numbers */
- int
- *FontSize = 0L; /* Array of Font Sizes */
- int
- nFontNumber=0, /* # of font Numbers */
- nFontSize = 0, /* # of font sizes */
- ScrlLock=0, /* Are we in network suspend mode */
- ftpavail=0, /* Is ftp available (default yes ) */ /* BYU 2.4.12 */
- ftplogon=0, /* Is ftp log visible (default no) */
- whichMenus=0; /* 0 is old 1 is new */
-
- extern SysEnvRec theWorld; /* BYU 2.4.18 - System Environment record */
-
- extern short
- serial_scrn, /* BYU 2.4.15 */
- slip_connection; /* BYU 2.4.15 */
-
- extern Cursor
- *graphcurs, /* Cursor when in graphic window */
- *normcurs; /* Cursor for non-transfer normal mode */
-
- extern Handle hKCHR; /* BYU 2.4.12 - Handle for keyboard mapping stuff (event.c) */
-
- THPrint
- prRecHdl=0L; /* our print record handle */
-
- MenuHandle
- myMenus[NMENUS]; /* Menu Handles .... */
-
- char
- stupidarray[150]; /* A stupid array for finding the stringwidth */
-
- short setdir;
-
- #define VMARGINS 4
-
- /*
- * External variable declarations (those which we borrow )
- *
- */
- extern WindRec
- *screens, /* The screen array from Maclook */
- ftplog, /* The FTP log screen from Maclook */
- console;
-
- extern short cmask;
-
- extern int
- done, /* BYU */
- KIP,
- MacBinary,
- EtherNet,
- dynamic,
- userlevel,
- ctrl, /* Control key ... */
- scrn, /* The current screen from Maclook */
- numwindows; /* The number of windows now from Maclook */
- extern int
- HasColor;
-
- long
- defmask, /* The network mask as per defaults contingent on the IP */
- mynetmask; /* The network mask as per user config */
-
- unsigned char
- KIPserver[4], /* BYU 2.4.15 - KIP gateway address */
- SLIP_ip_number[]; /* BYU 2.4.15 */
-
- DialogPeek myDPeek;
-
- char tempspot[256]; /* temporary storage */
-
-
- extern unsigned char
- myipnum[4], /* My current IP Number from Maclook */
- nnmyaddr[4]; /* My cuurent hardware address from Maclook */
-
- extern Str255
- *defaultd, /* Default host name */
- *dvs; /* Default Volume/directory specification */
- /*
- * Internal predeclared functions
- */
- pascal void
- VersionNumber(),
- OutlineItem();
- pascal short
- modalProc();
- void
- printsleep(); /* The netsleep/ print cancel procedure */
-
- PicHandle
- RGtoPICT(); /* Convert Drawings to pictures */
- int
- portsOpen(); /* 0 if none, 1 if active, -1 if not active */
-
-
- /*
- * External predeclared functions
- */
- extern char
- **RSGetTextSel(); /* Convert text to char handle from RSmac */
-
- char *strncpy();
-
- extern void close_mb_files(); /* BYU */
-
- #ifndef MPW
- Str255 *ptoc(),*ctop();
- #endif MPW
-
-
- CloseCaptureFile(int w) {
- VSclosecapture(w); /* BYU 2.4.18 */
- CheckItem(myMenus[Emul], EMcapture,FALSE); /* BYU 2.4.18 */
- }
-
-
- /* Allow the operator to "Switch to Serial" only when /* BYU 2.4.15 */
- /* all of the SLIP connections have been closed. /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- /* Allow the operator to "Switch to SLIP" only when /* BYU 2.4.15 */
- /* the front most session is a serial session. /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- SLIP_menus() { /* BYU 2.4.15 */
- short i; /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- if (serial_scrn>=0) { /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- if (!slip_connection) { /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- if (screens[scrn].connectionType == 0) /* BYU 2.4.15 */
- DisableItem (myMenus[Emul], EMslip); /* BYU 2.4.15 */
- else /* BYU 2.4.15 */
- EnableItem (myMenus[Emul], EMslip); /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- DisableItem (myMenus[Emul], EMserial); /* BYU 2.4.15 */
- CheckItem(myMenus[Emul], EMslip, FALSE); /* BYU 2.4.15 */
- CheckItem(myMenus[Emul], EMserial, TRUE); /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- } else { /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- DisableItem ( myMenus[Emul], EMslip); /* BYU 2.4.15 */
- CheckItem(myMenus[Emul], EMslip, TRUE); /* BYU 2.4.15 */
- CheckItem(myMenus[Emul], EMserial, FALSE); /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- i=0; /* BYU 2.4.15 */
- while((i<numwindows) && (screens[i].connectionType == 0)) /* BYU 2.4.15 */
- i++; /* BYU 2.4.15 */
- if (i>= numwindows) { /* BYU 2.4.15 */
- EnableItem (myMenus[Emul], EMserial); /* BYU 2.4.15 */
- } else { /* BYU 2.4.15 */
- DisableItem (myMenus[Emul], EMserial); /* BYU 2.4.15 */
- } /* BYU 2.4.15 */
- } /* BYU 2.4.15 */
- /* BYU 2.4.15 */
- } else { /* BYU 2.4.15 */
- DisableItem ( myMenus[Emul],EMslip); /* BYU 2.4.15 */
- DisableItem ( myMenus[Emul],EMserial); /* BYU 2.4.15 */
- if (slip_connection) { /* BYU 2.4.16 */
- CheckItem(myMenus[Emul], EMslip, TRUE); /* BYU 2.4.16 */
- CheckItem(myMenus[Emul], EMserial, FALSE); /* BYU 2.4.16 */
- } else { /* BYU 2.4.16 */
- CheckItem(myMenus[Emul], EMslip, FALSE); /* BYU 2.4.16 */
- CheckItem(myMenus[Emul], EMserial, TRUE); /* BYU 2.4.16 */
- } /* BYU 2.4.16 */
- } /* BYU 2.4.15 */
- } /* BYU 2.4.15 */
-
- void AdjustMenus
- (
- void
- )
- {
- int i;
-
- if ((i=portsOpen()) <1) {
- DisableItem( myMenus[Fil],FLclose);
- DisableItem( myMenus[Fil],FLsave);
- DisableItem( myMenus[Fil],FLprint);
- #ifdef CANTQUIT
- EnableItem ( myMenus[Fil],FLquit);
- #endif
- DisableItem( myMenus[Edit],EDcut);
- DisableItem( myMenus[Edit],EDundo);
- DisableItem( myMenus[Edit],EDclear);
- DisableItem( myMenus[Edit],EDcopy);
- DisableItem( myMenus[Edit],EDcopyt);
-
-
- DisableItem( myMenus[Emul],EMbs);
- DisableItem( myMenus[Emul],EMdel);
- DisableItem( myMenus[Emul],EMecho);
- DisableItem( myMenus[Emul],EMwrap);
- DisableItem( myMenus[Emul],EMscroll);
- DisableItem( myMenus[Emul],EMreset);
- DisableItem ( myMenus[Emul],EMjump);
- DisableItem ( myMenus[Emul],EMpage);
- DisableItem ( myMenus[Emul],EMclear); /* BYU 2.4.14 */
- DisableItem ( myMenus[Emul],EMlines);
- DisableItem ( myMenus[Emul],EMsetup);
- DisableItem ( myMenus[Emul],EMfont);
- DisableItem ( myMenus[Emul],EMsize);
- DisableItem ( myMenus[Emul],EMcolor);
- DisableItem ( myMenus[Emul],EMslip); /* BYU 2.4.15 */
- DisableItem ( myMenus[Emul],EMserial); /* BYU 2.4.15 */
- DisableItem ( myMenus[Emul],EMcapture); /* BYU 2.4.18 */
-
- DisableItem( myMenus[Net ],NEftp);
- DisableItem( myMenus[Net ],NEip);
- DisableItem( myMenus[Net ],NEayt);
- DisableItem( myMenus[Net ],NEao);
- DisableItem( myMenus[Net ],NEinter);
- DisableItem( myMenus[Net ],NEec);
- DisableItem( myMenus[Net ],NEel);
- DisableItem( myMenus[Net ],NEscroll);
- if (userlevel==0 )
- EnableItem( myMenus[Net], NEconfig);
-
- if (i<0) {
- EnableItem ( myMenus[Fil ],FLclose);
- }
- if (ScrlLock) {
- ScrlLock=0;
- CheckItem(myMenus[Net ], NEscroll,FALSE);
- }
- }
- else {
- EnableItem ( myMenus[Fil],FLclose);
- EnableItem ( myMenus[Fil],FLsave);
-
- /* EnableItem ( myMenus[Fil],FLprint); */
-
- #ifdef CANTQUIT
- DisableItem( myMenus[Fil],FLquit);
- #endif
-
- EnableItem ( myMenus[Emul],EMbs);
- EnableItem ( myMenus[Emul],EMdel);
- EnableItem ( myMenus[Emul],EMecho);
- EnableItem ( myMenus[Emul],EMwrap);
- EnableItem ( myMenus[Emul],EMscroll);
- EnableItem ( myMenus[Emul],EMreset);
- EnableItem ( myMenus[Emul],EMjump);
- EnableItem ( myMenus[Emul],EMpage);
- EnableItem ( myMenus[Emul],EMclear); /* BYU 2.4.14 */
- EnableItem ( myMenus[Emul],EMlines);
- EnableItem ( myMenus[Emul],EMsetup);
- EnableItem ( myMenus[Emul],EMfont);
- EnableItem ( myMenus[Emul],EMsize);
- EnableItem ( myMenus[Emul],EMcapture); /* BYU 2.4.18 */
-
- if (HasColor)
- EnableItem ( myMenus[Emul],EMcolor);
-
- EnableItem ( myMenus[Net ],NEftp);
- EnableItem ( myMenus[Net ],NEip);
- EnableItem ( myMenus[Net ],NEayt);
- EnableItem ( myMenus[Net ],NEao);
- EnableItem ( myMenus[Net ],NEinter);
- EnableItem ( myMenus[Net ],NEec);
- EnableItem ( myMenus[Net ],NEel);
- EnableItem ( myMenus[Net ],NEscroll);
- if (EtherNet == -99)
- EnableItem( myMenus[Net ],NEconfig);
- else
- DisableItem( myMenus[Net ],NEconfig);
- }
-
- SLIP_menus(); /* BYU 2.4.15 */
- }
-
- /*
- * switchMenus( which) - Switch from our current menus to the key menus (1)
- * or the normal menus (0).
- */
-
- void switchMenus
- (
- int which
- )
- {
- int i;
-
- DeleteMenu( fileMenu); /* Take them from the menu bar */
- DeleteMenu( editMenu);
- DeleteMenu( termMenu);
- DeleteMenu( netMenu);
-
- if (which) {
- myMenus[Fil ] = GetMenu(NfileMenu);
- myMenus[Edit] = GetMenu(NeditMenu);
- myMenus[Emul] = GetMenu(NtermMenu);
- myMenus[Net ] = GetMenu(NnetMenu );
- DelMenuItem(myMenus[Conn],1);
- InsMenuItem(myMenus[Conn],"\017Next Session/N\0",0);
- ctrl = optionKey; /* Option key is the control key.... */
- }
- else {
- myMenus[Fil ] = GetMenu(fileMenu);
- myMenus[Edit] = GetMenu(editMenu);
- myMenus[Emul] = GetMenu(termMenu);
- myMenus[Net ] = GetMenu( netMenu);
- DelMenuItem(myMenus[Conn],1);
- InsMenuItem(myMenus[Conn],"\015Next Session\0",0);
-
- ctrl = cmdKey; /* Command key is the control key... */
- }
-
- for(i=1; i<Conn; i++)
- InsertMenu( myMenus[i], connMenu); /* Put them in the menu bar */
-
- AdjustMenus(); /* Hilite the right stuff */
-
- if (MacBinary)
- CheckItem(myMenus[Fil],FLbin,TRUE); /* Check MacBinary ... */
- else
- CheckItem(myMenus[Fil],FLbin,FALSE);
-
- if (ftpavail)
- CheckItem(myMenus[Fil],FLftp,TRUE); /* Check ftpavail ... */
- else
- CheckItem(myMenus[Fil],FLftp,FALSE);
-
- if (ftplogon)
- CheckItem(myMenus[Fil],FLlog,TRUE); /* and the log .... */
- else
- CheckItem(myMenus[Fil],FLlog,FALSE);
-
- if (ScrlLock) /* and the Suspend network ... */
- CheckItem(myMenus[Net], NEscroll,TRUE);
- else
- CheckItem(myMenus[Net], NEscroll,FALSE);
-
- if (numwindows>0) /* and set the BSDEL flag */
- CheckItem(myMenus[Emul], EMbs+screens[scrn].bsdel,FALSE);
-
- /* SLIP_menus(); /* BYU 2.4.15 */
-
- DrawMenuBar(); /* Draw what we have done */
-
- SLIP_menus(); /* BYU 2.4.18 */
-
- if (userlevel!=0)
- DisableItem( myMenus[Net], NEconfig);
- if (!HasColor)
- DisableItem( myMenus[Emul], EMcolor);
-
- }
-
- /*
- * setupmenu - Set up (load) all menus and prepare menu bar.
- * set default check marks.
- */
-
- void setupmenu
- (
- int def
- )
- {
- int i;
- char temp[256];
-
- ftpavail = Sfmode(); /* Get the FTP Mode from session layer */
- for (i=0; i<150; i++) stupidarray[i]='W'; /* Set up the width array */
- myMenus[0] = GetMenu(appleMenu); /* Get all of our friendly menus */
- myMenus[Conn] = GetMenu(connMenu);
- myMenus[Font] = GetMenu(fontMenu);
- myMenus[Size] = GetMenu(sizeMenu);
-
- AddResMenu(myMenus[0], 'DRVR'); /* Add in the DA's */
-
- InsertMenu(myMenus[0], 0); /* Insert the Menus into the bar */
- InsertMenu(myMenus[Conn], 0);
- InsertMenu(myMenus[Font], -1);
- InsertMenu(myMenus[Size], -1);
-
-
- AddResMenu(myMenus[Font], 'FONT'); /* Put the fonts in the font menu */
-
- nFontNumber = i = CountMItems( myMenus[Font]); /* Initialize the FontNumber[] array*/
- (Ptr) FontNumber = NewPtr( sizeof(short) *(i+1));
- for (;i>0;i--) {
- getitem( myMenus[Font], i, temp);
- getfnum( temp, &FontNumber[i]); /* With the font numbers */
- }
-
- nFontSize = i = CountMItems( myMenus[Size]); /* Initialize the FontSize[] array */
- (Ptr) FontSize = NewPtr( sizeof(int) *(i+1));
- for (;i>0;i--) {
- getitem( myMenus[Size], i, temp);
- #ifndef MPW
- ptoc(temp);
- #endif MPW
- sscanf( temp, "%d", &FontSize[i]); /* Read from the resource itself */
- }
-
- FontNumber[0]=0;
- FontSize[0]=0;
-
- switchMenus(def);
- }
-
-
- /*
- * updateMenuChecks() - update the check marks for file transfer
- * (MacBinary and ftpavail)
- */
-
- void updateMenuChecks
- (
- void
- )
- {
- if (MacBinary)
- CheckItem(myMenus[Fil],FLbin,TRUE); /* Check MacBinary ... */
- else
- CheckItem(myMenus[Fil],FLbin,FALSE);
-
- ftpavail = Sfmode();
- if (ftpavail)
- CheckItem(myMenus[Fil],FLftp,TRUE); /* Check ftpavail ... */
- else
- CheckItem(myMenus[Fil],FLftp,FALSE);
- }
-
- /*
- * DisplayMacBinary() - Sets the macbinary check mark according to the
- * MacBinary flag
- */
-
- void DisplayMacBinary
- (
- void
- )
- {
- if (MacBinary)
- CheckItem(myMenus[Fil],FLbin,TRUE); /* Check MacBinary ... */
- else
- CheckItem(myMenus[Fil],FLbin,FALSE);
- }
-
- /*
- * CheckFonts() - Place checkmarks and outlines on the appropriate
- * menu items for the fonts
- */
-
- CheckFonts()
- {
- int i, fsiz, fnum;
-
- RSgetfont( screens[scrn].vs, &fnum, &fsiz);
-
- for(i=1; i<=nFontNumber;i++)
- if (fnum == FontNumber[i]) /* Check Our Current Font */
- CheckItem( myMenus[Font], i, TRUE);
- else
- CheckItem( myMenus[Font], i, FALSE);
-
- for(i=1; i<=nFontSize;i++) {
- if (fsiz == FontSize[i])
- CheckItem( myMenus[Size], i, TRUE); /* Check Our Current Size */
- else
- CheckItem( myMenus[Size], i, FALSE);
-
- if (RealFont( fnum, FontSize[i])) /* Outline All Available REAL Sizes */
- SetItemStyle( myMenus[Size], i, 8);
- else
- SetItemStyle( myMenus[Size], i, 0);
- }
- }
-
- /*
- * applAbout - display the about dialog for the application.
- * Displays until clicked on.
- */
- void applAbout
- (
- void
- )
- {
- DialogPtr About;
- short itemhit;
-
- About=GetNewDialog( 501, (Ptr) 0L,(WindowPtr) -1L);
- if (About) {
- ModalDialog((ModalFilterProcPtr) modalProc, &itemhit);
- DisposDialog(About);
- }
-
- About=GetNewDialog( 256, (Ptr) 0L,(WindowPtr) -1L);
- UItemAssign( About, 2, (int (*)()) VersionNumber);
- ModalDialog((ModalFilterProcPtr) modalProc, &itemhit);
- DisposDialog(About);
-
- }
-
- /*
- * configport - Used to reconfigure a session
- */
-
- int configport
- (
- ConfigRec *config
- )
- {
- /* struct machinfo *mp; */
- DialogPtr dtemp;
- int SBon=1, Del=1, width=80, tek=1,cr=1,echo=1,tektype,line,eightbit; /* BYU 2.4.9 */
- short dItem;
- Str255 temps,*tempp;
- Rect dBox;
- Handle host,name,scrlon,scrlnum,kbbs,kbdel,w132,w80,tekclear,tekcreate,
- crLF, crNUL,echoBuff,echoSend,tekold,teknew,lineyes,lineno, /* BYU 2.4.9 */
- eightyes,eightno; /* BYU 2.4.9 */
-
- Handle tekDis; /* NCSA 2.5 */
-
- SetCursor(normcurs);
-
- SBon=config->scrollback>0;
- Del=config->bsdel;
- width= config->width;
- tek= config->tekclear;
- cr = config->crmap == 10;
- echo = !config->halfdup;
- tektype = config->tektype;
- line = config->lineAllow;
- eightbit = config->eightbit; /* BYU 2.4.9 */
-
- tempp = (Str255 *) temps;
- dtemp=GetNewDialog( SConfigDLOG,(Ptr) 0L,(WindowPtr) -1L); /* Bring on the box */
- UItemAssign( dtemp, 25, (int (*)()) OutlineItem);
-
- #ifndef MPW
- config->machine=ctop(config->machine);
- #endif MPW
-
- GetDItem( dtemp, SChost, &dItem, &host, &dBox); /* Install the default host */
- setitext( host , config->machine);
-
- GetDItem( dtemp, SCname, &dItem, &name, &dBox); /* Install the default name */
- setitext( name, config->name); /* Here is default */
- SelIText( dtemp, SCname, 0, 32767); /* And select it... */
-
- GetDItem( dtemp, SCscrolnum, &dItem, &scrlnum, &dBox); /* Default Scrollback */
- sprintf((char *) tempp, "%d", SBon?config->scrollback:120);
- #ifndef MPW
- ctop(tempp);
- #endif MPW
- setitext( scrlnum, (char *) tempp);
-
- GetDItem( dtemp, SCscrolon, &dItem, &scrlon, &dBox); /* Get all of the handles now */
- GetDItem( dtemp, SCkbbs, &dItem, &kbbs, &dBox);
- GetDItem( dtemp, SCkbdel, &dItem, &kbdel, &dBox);
- GetDItem( dtemp, SCwidth132, &dItem, &w132, &dBox);
- GetDItem( dtemp, SCwidth80, &dItem, &w80, &dBox);
- GetDItem( dtemp, SCtekclear, &dItem, &tekclear, &dBox);
- GetDItem( dtemp, SCtekcreate, &dItem, &tekcreate, &dBox);
- GetDItem( dtemp, SCcrLF, &dItem, &crLF, &dBox);
- GetDItem( dtemp, SCcrNUL, &dItem, &crNUL, &dBox);
- GetDItem( dtemp, SCechoBuff, &dItem, &echoBuff, &dBox);
- GetDItem( dtemp, SCechoSend, &dItem, &echoSend, &dBox);
- GetDItem( dtemp, SCtekold, &dItem, &tekold, &dBox);
- GetDItem( dtemp, SCteknew, &dItem, &teknew, &dBox);
- GetDItem( dtemp, SClineY, &dItem, &lineyes, &dBox);
- GetDItem( dtemp, SClineN, &dItem, &lineno, &dBox);
- GetDItem( dtemp, SCeightY, &dItem, &eightyes, &dBox); /* BYU 2.4.9 */
- GetDItem( dtemp, SCeightN, &dItem, &eightno, &dBox); /* BYU 2.4.9 */
- GetDItem( dtemp, SCtekdis, &dItem, &tekDis, &dBox); /* NCSA 2.5 */
-
- /* HiliteControl(w132, 255); */
-
- SetCtlValue((ControlHandle) scrlon, SBon);
- SetCtlValue((ControlHandle) kbdel, Del);
- SetCtlValue((ControlHandle) kbbs, !Del);
- SetCtlValue((ControlHandle) w132, (width==132));
- SetCtlValue((ControlHandle) w80, !(width==132));
- SetCtlValue((ControlHandle) tekcreate, !tek);
- SetCtlValue((ControlHandle) tekclear , tek);
- SetCtlValue((ControlHandle) crLF , cr);
- SetCtlValue((ControlHandle) crNUL, !cr);
- SetCtlValue((ControlHandle) echoBuff, echo);
- SetCtlValue((ControlHandle) echoSend, !echo);
- SetCtlValue((ControlHandle) tekold, (tektype== 0)); /* NCSA 2.5 */
- SetCtlValue((ControlHandle) teknew, (tektype== 1)); /* NCSA 2.5 */
- SetCtlValue((ControlHandle) tekDis, (tektype== -1)); /* NCSA 2.5 */
- SetCtlValue((ControlHandle) lineyes, line);
- SetCtlValue((ControlHandle) lineno, !line);
- SetCtlValue((ControlHandle) eightyes, eightbit); /* BYU 2.4.9 */
- SetCtlValue((ControlHandle) eightno, !eightbit); /* BYU 2.4.9 */
-
-
- dItem=0; /* initially no hits */
- while((dItem>2) || (dItem==0)) { /* While we are in the loop */
- ModalDialog((ModalFilterProcPtr)modalProc,&dItem); /* and do our duty to the box */
- switch( dItem) {
- case SCscrolon:
- SBon=!SBon;
- SetCtlValue((ControlHandle) scrlon, SBon);
- break;
- case SCkbbs:
- Del=0;
- SetCtlValue((ControlHandle) kbbs, !Del);
- SetCtlValue((ControlHandle) kbdel, Del);
- break;
- case SCkbdel:
- Del=1;
- SetCtlValue((ControlHandle) kbdel, Del);
- SetCtlValue((ControlHandle) kbbs, !Del);
- break;
- case SCwidth132:
- width=132;
- SetCtlValue((ControlHandle) w132, (width==132));
- SetCtlValue((ControlHandle) w80, (width!=132));
- break;
- case SCwidth80:
- width=80;
- SetCtlValue((ControlHandle) w132, (width==132));
- SetCtlValue((ControlHandle) w80, (width!=132));
- break;
- case SCtekclear:
- tek=1;
- SetCtlValue((ControlHandle) tekcreate, !tek);
- SetCtlValue((ControlHandle) tekclear , tek);
- break;
- case SCtekcreate:
- tek=0;
- SetCtlValue((ControlHandle) tekcreate, !tek);
- SetCtlValue((ControlHandle) tekclear , tek);
- break;
- case SCcrLF:
- cr=1;
- SetCtlValue((ControlHandle) crLF , cr);
- SetCtlValue((ControlHandle) crNUL, !cr);
- break;
- case SCcrNUL:
- cr=0;
- SetCtlValue((ControlHandle) crLF , cr);
- SetCtlValue((ControlHandle) crNUL, !cr);
- break;
- case SCechoBuff:
- echo=1;
- SetCtlValue((ControlHandle) echoBuff, echo);
- SetCtlValue((ControlHandle) echoSend, !echo);
- break;
- case SCechoSend:
- echo=0;
- SetCtlValue((ControlHandle) echoBuff, echo);
- SetCtlValue((ControlHandle) echoSend, !echo);
- break;
- case SCtekold:
- tektype=0;
- SetCtlValue((ControlHandle) tekold, !tektype);
- SetCtlValue((ControlHandle) teknew, (tektype==1)); /* NCSA 2.5 */
- SetCtlValue((ControlHandle) tekDis, 0); /* NCSA 2.5 */
- break;
- case SCteknew:
- tektype=1;
- SetCtlValue((ControlHandle) tekold, !tektype);
- SetCtlValue((ControlHandle) teknew, (tektype==1));
- SetCtlValue((ControlHandle) tekDis, 0); /* NCSA 2.5 */
- break;
- case SCtekdis: /* NCSA 2.5 */
- tektype= -1; /* NCSA 2.5 */
- SetCtlValue((ControlHandle) tekold, !tektype); /* NCSA 2.5 */
- SetCtlValue((ControlHandle) teknew, (tektype==1)); /* NCSA 2.5 */
- SetCtlValue((ControlHandle) tekDis, 1); /* NCSA 2.5 */
- break; /* NCSA 2.5 */
- case SClineY:
- line=1;
- SetCtlValue((ControlHandle) lineyes, line);
- SetCtlValue((ControlHandle) lineno, !line);
- break;
- case SClineN:
- line=0;
- SetCtlValue((ControlHandle) lineyes, line);
- SetCtlValue((ControlHandle) lineno, !line);
- break;
- case SCeightY: /* BYU 2.4.9 */
- eightbit=1; /* BYU 2.4.9 */
- SetCtlValue((ControlHandle) eightyes, eightbit); /* BYU 2.4.9 */
- SetCtlValue((ControlHandle) eightno, !eightbit); /* BYU 2.4.9 */
- break; /* BYU 2.4.9 */
- case SCeightN: /* BYU 2.4.9 */
- eightbit=0; /* BYU 2.4.9 */
- SetCtlValue((ControlHandle) eightyes, eightbit); /* BYU 2.4.9 */
- SetCtlValue((ControlHandle) eightno, !eightbit); /* BYU 2.4.9 */
- break; /* BYU 2.4.9 */
- }
- }
-
- if (dItem==DLOGCancel) {
- DisposDialog( dtemp);
- updateCursor(1);
- return(0);
- }
-
- getitext( host, config->machine); /* where do we go from here? */
- getitext( name, config->name); /* And what is its name ... */
- if ( *config->name == 0 ) {
- getitext( host, config->name); /* Copy the host name in ... */
- }
- getitext( scrlnum, (char *) tempp); /* here is our ascii number */
-
- #ifndef MPW
- tempp= (Str255 *)ptoc(tempp);
- #endif
-
- DisposDialog( dtemp);
- updateCursor(1);
-
- #ifndef MPW
- config->machine=ptoc(config->machine);
- #endif
-
- config->scrollback=120; /* Make certain that number will be valid */
- if ( SBon) {
- if (sscanf((char *) tempp, "%d", &config->scrollback) !=1) {
- config->scrollback=0;
- SBon = 0;
- }
- }
- else
- config->scrollback=0;
- config->lineAllow=line;
- config->eightbit=eightbit; /* BYU 2.4.9 */
- config->bsdel=Del;
- config->tektype=tektype;
- config->width=width;
- config->tekclear=tek;
- config->halfdup= !echo;
- if (cr)
- config->crmap= 0x0a;
- else
- config->crmap= 0x00;
-
- return(1);
- } /* configport */
-
-
-
- pascal Boolean theProc(theDialog,theEvent,theItem)
- DialogPtr theDialog;
- EventRecord *theEvent;
- short *theItem;
- {
- int ascii;
- OSErr err;
-
-
- if (theEvent->what==keyDown || theEvent->what==autoKey)
- {
- ascii = theEvent->message & charCodeMask;
- if (ascii==CR || ascii==3)
- {
- *theItem = 1;
- return 1;
- }
-
- if (theEvent->modifiers & cmdKey && theEvent->modifiers&shiftKey)
- if (ascii=='.')
- {
- *theItem =2;
- return 1;
- }
-
- if (theEvent->modifiers&cmdKey)
- {
- switch (ascii)
- {
-
- case 'v': err=TEFromScrap();
- DlgPaste(theDialog);
- /*TEPaste(myDPeek.textH);*/
- *theItem=5;
- return 1;
- break;
- case 'c':
- DlgCopy(theDialog);
- ZeroScrap();
- err=TEToScrap();
- *theItem=5;
- return 1;
- break;
- case 'x':
- DlgCut(theDialog);
- ZeroScrap();
- err=TEToScrap();
- *theItem=5;
- return 1;
- break;
- }
- }
-
-
- if (theEvent->modifiers & ( optionKey | controlKey | cmdKey))
- {
- SysBeep(1);
- *theItem=5;
- return 1;
- }
-
- if (isalnum(ascii) || (ascii=='.') || (ascii=='-') || (ascii==BS) || (ascii==' ') || (ascii==TAB));
- return 0;
-
-
- SysBeep(1);
- *theItem=5;
- return 1;
- }
- return 0;
- }
-
-
-
-
-
-
- /*
- * setupport - Used to start a session
- */
-
- void setupport(theFtpFlag)
- short theFtpFlag;
-
- {
- short cc;
- DialogPtr dtemp;
- ConfigRec config;
- int ftponly,oldscrn,serialonly; /* BYU 2.4.15 */
- short dItem,myDitem;
- Str255 temps,*tempp;
- Rect dBox,myRect;
- Handle sessiontype,host,name,myHandle,okHandle; /* BYU 2.4.15 */
- static numWind=1;
- char aTempStr[4];
- register short i;
- AliasRecord theAliasRec; /* NCSA: data for this alias */
-
- /* struct machinfo *mp; */
-
- tempp = (Str255 *) temps;
-
- configdefault( &config); /* Start with the lowest of the low */
- if (theFtpFlag) config.ftpwind = 1;
-
- { char *p;
- if (NULL == (p = NewPtr(40000))) { /* do we have enough memory? */
-
- #ifndef MPW
- OtherError("\PNo memory for connnection","\P ");
- #else
- OtherError("Not enough memory left to open"," ");
- #endif MPW
- return;
- }
- else
- DisposPtr(p);
- }
-
- config.name=NewPtr(256); /* Get some space for our name */
- config.machine=NewPtr(256); /* Get some space for our name */
- for (cc=0;cc<255;cc++)
- config.machine[cc] =0;
-
- dtemp=GetNewDialog( SessionDLOG,(Ptr) myDPeek,(WindowPtr) -1L); /* Bring on the box */
- UItemAssign( dtemp, 8, (int (*)()) OutlineItem);
-
- SetCursor(normcurs);
-
- GetDItem( dtemp, Shost, &dItem, &host, &dBox); /* Install the default host */
- setitext( host , (char *) defaultd);
- SelIText( dtemp, Shost, 0, 32767); /* And select it... */
- GetDItem(dtemp,3,&myDitem,&myHandle,&myRect);
- GetDItem(dtemp,3,&myDitem,&okHandle,&dBox);
-
- GetDItem( dtemp, Sname, &dItem, &name, &dBox); /* Install the default name */
- /* setitext( name, defaultd); No Default */
-
-
- modalItems = 2; /* BYU 2.4.15 - indicate number of cmd keys active */
- modalItem[0] = 9; /* BYU 2.4.15 - enable modal cmd key feature on item 9 */
- modalKey[0] = 3; /* BYU 2.4.15 - cmd F key toggles FTP session button */
- modalItem[1] = 10; /* BYU 2.4.15 - enable modal cmd key feature on item 10 */
- modalKey[1] = 1; /* BYU 2.4.15 - cmd S key toggles Serial session button */
-
- ftponly = 0; /* BYU */
-
- if (EtherNet == -100) { /* BYU 2.4.15 */
- serialonly = 1; /* BYU 2.4.15 */
- GetDItem( dtemp, Sserialonly, &dItem, &sessiontype, &dBox); /* BYU 2.4.15 */
- SetCtlValue( (ControlHandle) sessiontype, serialonly); /* BYU 2.4.15 */
- HiliteControl((ControlHandle) sessiontype, 255); /* BYU 2.4.15 */
- if (!slip_connection) { /* BYU 2.4.15 */
- GetDItem( dtemp, Sftponly, &dItem, &sessiontype, &dBox); /* BYU 2.4.15 */
- HiliteControl((ControlHandle) sessiontype, 255); /* BYU 2.4.15 */
- } /* BYU 2.4.15 */
- } else /* BYU 2.4.15 */
- serialonly = 0; /* BYU 2.4.15 */
-
- dItem=0; /* initially no hits */
- getitext( host, config.machine); /* where do we go from here? */
-
-
-
- while((dItem>3) || (dItem==0)) /* While we are in the loop */
- {
-
- if (*config.machine == 0)
- {
- HiliteControl((ControlHandle)myHandle,255);
- /* HiliteControl((ControlHandle)okHandle,255); */
- }
- else
- {
- HiliteControl((ControlHandle)myHandle,0);
- /* HiliteControl((ControlHandle)okHandle,0); */
- }
-
- ModalDialog((ModalFilterProcPtr) modalProc,&dItem); /* BYU - and do our duty to the box */
- if (dItem == Sftponly && (EtherNet != -100 || slip_connection)) { /* BYU 2.4.16 */
- ftponly = 1 - ftponly; /* BYU - Toggle ftp session flag */
- GetDItem( dtemp, Sftponly, &dItem, &sessiontype, &dBox); /* BYU serial */
- SetCtlValue( (ControlHandle) sessiontype, ftponly); /* BYU serial */
- if ((slip_connection == 0) && (EtherNet != -100)) { /* BYU 2.4.15 */
- serialonly = 0; /* BYU serial */
- GetDItem( dtemp, Sserialonly, &dItem, &sessiontype, &dBox); /* BYU serial */
- SetCtlValue( (ControlHandle) sessiontype, serialonly); /* BYU serial */
- } /* BYU 2.4.15 */
- } else if (dItem == Sserialonly && EtherNet != -100) { /* BYU 2.4.16 */
- serialonly = 1 - serialonly; /* BYU serial */
- GetDItem( dtemp, Sserialonly, &dItem, &sessiontype, &dBox); /* BYU serial */
- SetCtlValue( (ControlHandle) sessiontype, serialonly); /* BYU serial */
- if (slip_connection == 0) { /* BYU 2.4.15 */
- ftponly = 0; /* BYU serial - Toggle ftp session flag */
- GetDItem( dtemp, Sftponly, &dItem, &sessiontype, &dBox); /* BYU serial */
- SetCtlValue( (ControlHandle) sessiontype, ftponly); /* BYU serial */
- } /* BYU 2.4.15 */
- } /* BYU serial */
- getitext( host, config.machine); /* where do we go from here? */
- #ifdef NOT if (*config.machine == 0)
- {
- HiliteControl((ControlHandle)myHandle,255);
-
- else
- HiliteControl((ControlHandle)myHandle,0);
- #endif
- }
-
- modalItems = 0; /* BYU serial - disable modal cmd key feature */
-
- if (dItem==DLOGCancel) {
- DisposPtr( config.name); /* Don't need this if we throw it out */
- DisposPtr( config.machine); /* D I T T O ........................ */
- DisposDialog( dtemp);
- return;
- }
-
- getitext( host, config.machine); /* where do we go from here? */
-
- /* NCSA: now that we have the name of the host, check to see if it
- is really just an alias. If it is, then give us the REAL
- name, along with the port number tacked on to the end. */
-
- if (GetDataFromAlias(config.machine, &theAliasRec) ==1)
- {
- char junk[10];
-
- strcpy(config.machine,theAliasRec.name);
- sprintf (junk," %d",theAliasRec.port);
- strcat(config.machine,junk);
- }
-
- getitext( name, config.name); /* And what is its name ... */
- if ( *config.name == 0 ) {
- getitext( host, config.name); /* Copy the host name in ... */
- sprintf(aTempStr," %i",(int)numWind);
- strcat(config.name,aTempStr);
- }
-
- for (i=0;config.machine[i];i++)
- if (!isprint(config.machine[i])) config.machine[0]=0;
-
- if ( *config.machine == 0 && !serialonly) { /* BYU 2.4.18 */
- DisposPtr( config.name); /* Don't need this if we throw it out */
- DisposPtr( config.machine); /* D I T T O ........................ */
- DisposDialog( dtemp);
- return;
- }
- DisposDialog( dtemp);
-
- updateCursor(1);
-
- #ifndef MPW
- config.machine=ptoc(config.machine);
- #endif
- primeConfig( &config);
- if (theFtpFlag) config.ftpwind =1;
-
- if (dItem == 3) /* Reconfigure port if applicable */
- if (!configport( &config)) {
- DisposPtr(config.name);
- DisposPtr(config.machine);
- return;
- }
- config.connectionType = serialonly; /* BYU 2.4.15 */
-
- config.ftpstate = ftponly; /* BYU */
- if (ftponly != 0) { /* BYU */
- config.halfdup = 1; /* BYU */
- } /* BYU */
-
- putln("Going addport");
- oldscrn=addport( &config ); /* Make our user window */
- numWind++;
-
- if (oldscrn<0) {
- DisposPtr(config.name);
- DisposPtr(config.machine);
- return;
- }
- } /* setupport */
-
- int ReallyClose
- (
- int scrn
- )
- {
- DialogPtr dtemp;
- short item;
-
- SetCursor(normcurs);
-
- paramtext(screens[scrn].name,0L,0L,0L);
- dtemp = GetNewDialog( CloseDLOG,(Ptr) 0L,(WindowPtr) -1L);
- UItemAssign( dtemp, 3,(int (*)()) OutlineItem);
-
- item = DLOGCancel +1;
-
- while (item> DLOGCancel)
- ModalDialog((ModalFilterProcPtr) modalProc, &item);
-
- DisposDialog( dtemp);
-
- updateCursor(1);
-
- if (item ==DLOGCancel) {
- return(0);
- }
-
- return(1);
- }
-
- void LoadCONF
- (
- void
- )
- {
- SFReply sfr;
- long typesok='CONF';
- Point where;
-
- where.h=100;where.v=100;
- #ifndef MPW
- sfgetfile( pass(where), "\PSet to load:", 0L, 1, &typesok,
- 0L, &sfr);
- #else
- sfgetfile( pass(where), "Set to load:", 0L, 1, (SFTypeList) &typesok,
- 0L, &sfr);
- #endif MPW
-
-
- if (! sfr.good)
- return;
-
- setvol(0L, sfr.vRefNum);
- p2cstr(&sfr.fName);
- readconfig(&sfr.fName);
- setmydir(); /* restore default dir for FTP */
- }
-
- void SaveCONF
- (
- void
- )
- {
- SFReply sfr;
- FILE *fp;
- long typesok='CONF';
- WindowPeek wpeek;
- Rect rect;
- Point where;
- char temp[256];
- unsigned int red,green,blue;
- int fnum,fsiz;
- int i;
-
- where.h = 100; where.v = 100;
- #ifndef MPW
- sfputfile( pass(where), "\PSave Set to:", "\PTelnet Set", 0L, &sfr);
- #else
- sfputfile( pass(where), "Save Set to:", "Telnet Set", 0L, &sfr);
- #endif
-
- if (! sfr.good)
- return;
-
- setvol(0L, sfr.vRefNum);
- p2cstr(&sfr.fName);
- create(&sfr.fName, sfr.vRefNum, 'NCSA', 'CONF');
-
-
- fp = fopen(&sfr.fName, "w");
-
- if (whichMenus)
- fprintf(fp, "commandkeys = yes\015");
- else
- fprintf(fp, "commandkeys = no\015");
-
- for (i = 0; i < 10; i++)
- {
- getmacro(i, temp);
- if (*temp)
- fprintf(fp, "key%d = \"%s\"\015", i, temp);
- } /* for */
-
- for (i = 0; i < numwindows; i++)
- {
- int j;
- j = RSgetfont(screens[i].vs, &fnum, &fsiz);
- sprintf(temp,"code: %d. Window %d has fnum,fsize = %d, %d",j,i,fnum,fsiz);
- putln(temp);
- } /* for */
-
- for (i = 0; i < numwindows; i++)
- {
- strncpy( temp, screens[i].name, 255);
- fprintf( fp, "name= \"%s\"\015", ptoc(temp));
-
- strncpy( temp, screens[i].machine, 255);
- fprintf( fp, "host= \"%s\"\015", ptoc(temp));
-
- if (screens[i].connectionType == 1) /* BYU 2.4.15 */
- fprintf( fp, "serial= yes\015"); /* BYU 2.4.15 */
- else if (screens[i].ftpstate != 0) /* BYU 2.4.15 */
- fprintf( fp, "ftp= yes\015"); /* BYU mod */
-
- fprintf (fp,"port= %d\015",screens[i].portNum); /* NCSA: save port # */
-
- fprintf( fp, "scrollback= %d\015", (screens[i].maxscroll));
-
- if (screens[i].bsdel)
- fprintf( fp, "erase = delete\015");
- else
- fprintf( fp, "erase = backspace\015");
-
- wpeek = (WindowPeek) screens[i].wind;
- rect = (*wpeek->contRgn)->rgnBBox;
-
- fprintf( fp, "size = {%d,%d,%d,%d}\015", rect.top, rect.left,
- rect.bottom, rect.right);
-
- fprintf( fp, "vtwidth = %d\015", screens[i].width);
-
- if (screens[i].tekclear)
- fprintf( fp, "tekclear = yes\015");
- else
- fprintf( fp, "tekclear = no\015");
-
- if (HasColor)
- {
- int j;
- for (j = 0; j < 4; j++)
- {
- RSgetcolor( screens[i].vs, j, &red, &green, &blue);
- fprintf( fp, "rgb%d = {%u,%u,%u}\015", j, red, green, blue);
- } /* for j */
- } /* if */
- RSgetfont( screens[i].vs, &fnum, &fsiz);
- getfontname( fnum, temp);
- #ifndef MPW
- ptoc(temp);
- #endif
-
- fprintf( fp, "font = \"%s\"\015", temp);
- fprintf( fp, "fsize= %d\015", fsiz);
-
- fprintf( fp, "nlines= %d\015", VSgetlines(screens[i].vs));
- fprintf( fp, "keystop= %d\015", screens[i].TELstop);
- fprintf( fp, "keygo= %d\015", screens[i].TELgo);
- fprintf( fp, "keyip= %d\015", screens[i].TELip);
- fprintf( fp, "crmap= %d\015", screens[i].crmap);
- fprintf( fp, "\015"); /* I hate messy files */
- } /* for i */
- fclose(fp);
- setmydir(); /* restore default dir for FTP */
- } /* SaveCONF */
-
- /*************************************************************************/
- /* Change transfer directory for FTP
- */
-
- pascal short FileHook
- (
- short item,
- DialogPtr theDialog
- )
- {
- #pragma unused(theDialog)
- if(item == 11) { /* Set Directory Button */
- setdir = 1;
-
- return(3); /* pretend we hit cancel, but we didn't */
- }
- else if (item == 12 || item == 13)
- item = 9; /* these don't count, map to disabled item */
-
- return(item);
- }
-
- /*
- * wdset - set the working directory for FTP's
- */
-
- int wdset
- (
- void
- )
- {
- Point where;
- SFReply reply;
-
- where.h=100;where.v=100;
- setdir = 0; /* clear dir found flag */
-
- setmydir();
- sfpgetfile( &where, "Default receive Directory", NULL, -1, NULL,
- (DlgHookProcPtr) FileHook, &reply, 4001,
- (ModalFilterProcPtr) modalProc);
-
- if (setdir) /* we got a dir */
- setSFdir();
- else {
- if(!reply.good) return(-1); /* real cancel button got hit */
- makemydir(reply.vRefNum); /* chose a file */
- }
- return(0);
- } /* wdset */
-
- /*
- * printGraph - Print the graphics on the current window
- * vg - which graphics window to print
- */
-
- void printGraph
- (
- int dnum /* Which drawing to print */
- )
- {
- int h,v; /* used for centering (h=horiz. , v=vert.) */
- int wh,wv; /* Window horiz and vert */
- TPrStatus
- prStatus; /* Printing status record */
- Rect prRect; /* the rectangle to print in */
- TPPrPort prPort; /* the printing port */
- int j; /* VG identifier for pass-through */
-
- SetCursor(normcurs);
-
- if (PrJobDialog(prRecHdl)) { /* Cancel the print if FALSE */
- prPort=PrOpenDoc(prRecHdl,0L,0L); /* Open Printer Port */
- if (PrError() == 0) { /* If we can't, then die */
- PrOpenPage(prPort, 0L); /* Open a page */
-
- (*prRecHdl)->prJob.pIdleProc = (PrIdleProcPtr) printsleep; /* our sleep/cancel*/
-
- prRect=PGRECT; /* Get the page rectangle */
- h=prRect.right - prRect.left; /* Get the width */
- v=prRect.bottom- prRect.top; /* Get the height */
- if (3*h<4*v) { /* Center the little bugger */
- wh = h;
- wv = (3 * h)/ 4;
- }
- else { /* On the page rectangle */
- wv = v;
- wh = (4 * v)/ 3;
- }
-
- prRect.top = (v- wv) /2;
- prRect.left = (h- wh) /2;
- prRect.bottom = prRect.top + wv;
- prRect.right = prRect.left + wh;
-
- j=VGnewwin(3,VGgetVS(dnum)); /* NCSA 2.5: fixed the print call */
- RGMPsize( &prRect );
- VGzcpy( dnum, j); /* Love dat zm factr */
- VGredraw(dnum,j); /* Copy the picture in i to j */
- VGclose(j); /* OK, we're done, give it to someone else */
- PrClosePage(prPort); /* Page out.... */
- }
-
- PrCloseDoc(prPort); /* Done with the document */
- putln("Doc is closed... the printing begins....");
-
- #if 1 /* BYU 2.4.20 */
- if (PrError()==0) /* BYU 2.4.20 - changed for HP DeskWriter*/
- #else /* BYU 2.4.20 */
- if (((*prRecHdl)->prJob.bJDocLoop == bSpoolLoop) && (PrError()==0))
- #endif /* BYU 2.4.20 */
- PrPicFile(prRecHdl,0L,0L,0L,&prStatus);
- /* Print the spooled file if applicable */
- } /* if PrJobDialog */
-
- updateCursor(1);
- }
-
- /*
- * printPages(prPort,charh,title, columns) -
- * Prints <charh> on the printer through port <prPort> with <title>
- * using <columns>.
- */
- void printPages
- (
- TPPrPort prPort, /* the Printer port */
- char **charh,
- Str255 *Title,
- int columns,
- int theScreen
- )
- {
- char *charp, *start;
- long charlen,count=0L;
- int v,h,vloc,scount=0, lines=0, pgcount=1, pgtmplen, maxlines;
- char pagetemp[20];
- FMetricRec info;
- Fixed columnF;
- int Fheight, Fwidth;
- int ww;
-
- if ( ((*prRecHdl)->prStl.wDev>>8) !=3 ) {
- /* Think about this: put def. font in rsrc fork- STR255 */
- TextFont(4); /* MONACO */
- v=9;
- }
- else {
- TextFont(22); /* or courier */
- v=14;
- }
- columnF = FixRatio( columns, 1);
- TextFont((*(screens[theScreen].wind)).txFont);
- TextFace((*(screens[theScreen].wind)).txFace);
- v = (*(screens[theScreen].wind)).txSize;
-
- TextSize(v);
- FontMetrics( &info );
- Fheight = FixRound( info.ascent + info.descent + info.leading);
- Fwidth = FixRound( info.widMax);
- Fwidth = CharWidth('W'); /* Re-assign to largest char */
-
- v--;
- ww = TextWidth( stupidarray,0,columns);
-
-
- HLock(charh);
- start=charp=*charh;
- charlen= GetHandleSize(charh);
-
- h=PGRECT.right - PGRECT.left; /* Get the width */
- v=PGRECT.bottom- PGRECT.top; /* Get the height */
-
- maxlines= (v / Fheight) - 2*VMARGINS -1; /* Get maxlines */
- vloc= VMARGINS;
-
- while (count<charlen) {
- PrOpenPage(prPort, 0L); /* Open the Printer Page */
- (*prRecHdl)->prJob.pIdleProc = (PrIdleProcPtr) printsleep; /* our netsleep */
-
- MoveTo( 0, (VMARGINS-2)*Fheight);
- drawstring("Session Name: ");
-
- drawstring((char *) Title);
- sprintf(pagetemp, "Page %d", pgcount);
- pgtmplen=strlen(pagetemp);
- MoveTo( h-(pgtmplen * Fwidth), (VMARGINS-2)*Fheight);
- DrawText( pagetemp, 0, pgtmplen);
- vloc=VMARGINS;
-
- while (lines < maxlines && count<charlen) {
- while ((count<charlen) && (*charp++!='\n')) { count++; scount++; }
- MoveTo(0,vloc++*Fheight);
- if (scount>0)
- DrawText(start, 0, scount);
- count++;
- lines++;
- scount=0;
- start=charp;
- }
-
- vloc=VMARGINS;
- PrClosePage(prPort); /* Close the Printer page */
- lines=0;
- pgcount++;
- }
- HUnlock(charh);
- }
-
- /*
- * printText - Print the text selected on the screen
- * vs - which vs to print from
- */
-
- void printText
- (
- int vs, /* Which screen to print */
- Str255 *Title, /* The title string */
- int theScreen
- )
- {
- char **charh; /* The character handle */
- TPrStatus prStatus; /* Status record */
- TPPrPort prPort; /* the Printer port */
-
- charh = RSGetTextSel(vs,0); /* Get the characters to print */
-
- if ( charh==0L)
- return; /* don't print nothing.... */
-
- SetCursor(normcurs);
-
- if (PrJobDialog(prRecHdl)) { /* Cancel the print if FALSE */
- prPort=PrOpenDoc(prRecHdl,0L,0L);
- if (PrError() == 0) {
- printPages( prPort, charh, Title, VSmaxwidth(vs),theScreen);
- /* Draw the text */
- }
- PrCloseDoc(prPort);
-
- if (((*prRecHdl)->prJob.bJDocLoop == bSpoolLoop) && (PrError()==0))
- PrPicFile(prRecHdl,0L,0L,0L,&prStatus); /* Spool the print */
- /* If necessary..... */
- }
- HPurge(charh); /* Kill the printed chars */
- updateCursor(1);
- }
-
- int ReallyQuit
- (
- void
- )
- {
- DialogPtr dtemp;
- short item;
-
- SetCursor(normcurs);
-
- dtemp = GetNewDialog( QuitDLOG,(Ptr) 0L,(WindowPtr) -1L);
- UItemAssign( dtemp, 3, (int (*)()) OutlineItem);
-
- item = DLOGCancel +1;
-
- while (item> DLOGCancel)
- ModalDialog((ModalFilterProcPtr) modalProc, &item);
-
- DisposDialog( dtemp);
-
- updateCursor(1);
-
- if (item ==DLOGCancel) {
- return(0);
- }
-
- return(1);
- }
-
- void quit
- (
- void
- )
- {
- if (numwindows>0)
- return;
-
- if (hKCHR) /* BYU 2.4.12 */
- ReleaseResource(hKCHR); /* BYU 2.4.12 */
-
- if (theWorld.systemVersion < 0x0700) /* BYU 2.4.18 */
- optionKeysOff(); /* BYU 2.4.18 */
-
- PortClose(); /* BYU serial - make sure serial port is closed */
- netshut();
- PrClose();
- putln("got here\015"); /* BYU 2.4.18 - changed \n to \015 */
-
- if (EtherNet == -99) /* BYU 2.4.16 */
- CloseResolver(); /* BYU 2.4.16 */
-
- close_mb_files(); /* BYU - Don't leave any files open! */
- done = 1; /* BYU */
- }
-
- /*
- * copyGraph - Copy the current graphics screen.
- * dnum - the number of the drawing to copy .
- */
-
- void copyGraph
- (
- int dnum
- )
- {
- long tlong; /* Temporary Variable */
- PicHandle tpic; /* Mental picture of the thing */
-
- tpic=RGtoPICT(dnum); /* Get the picture */
- tlong=ZeroScrap(); /* Nobody else can live here */
- HLock((Handle) tpic); /* Lock it for Puting */
- tlong=PutScrap(GetHandleSize((Handle) tpic),'PICT', (Ptr) *tpic); /* Store as a PICT */
- HUnlock((Handle) tpic); /* Unlock so we can toss it */
- KillPicture(tpic); /* Kill the picture..... */
- }
-
- /*
- * copyText - Copy the current selection on the virtual screen
- * vs - the number of the virtual screen to copy from
- */
-
- void copyText
- (
- int vs
- )
- {
- char **charh; /* where to store the characters */
- long tlong; /* Necessary temporary variable */
-
- tlong=ZeroScrap(); /* This Scrap aint big enough for the both of us */
-
- charh=RSGetTextSel(vs,0); /* Get the text selection */
-
- if (charh!= (char *)0L && charh!= (char *)-1L) { /* Can't do anything without characters */
- HLock(charh); /* Lock for putting */
- tlong=PutScrap(GetHandleSize(charh),'TEXT',*charh);
- /* Put it as a TEXT resource */
- HUnlock(charh); /* Unlock for disposal */
- DisposHandle(charh); /* Kill the chars */
- }
- else putln("No characters to copy darn it!");
- }
-
- /*
- * copyTable - Copy the current selection on the virtual screen
- * vs - the number of the virtual screen to copy from
- */
-
- void copyTable
- (
- int vs
- )
- {
- char **charh; /* where to store the characters */
- long tlong; /* Necessary temporary variable */
-
- tlong=ZeroScrap(); /* This Scrap aint big enough for the both of us */
-
- charh=RSGetTextSel(vs, Prefs.CTthresh); /* Get the text selection */
-
- if (charh>0L) { /* Can't do anything without characters */
- HLock(charh); /* Lock for putting */
- tlong=PutScrap(GetHandleSize(charh),'TEXT',*charh);
- /* Put it as a TEXT resource */
- HUnlock(charh); /* Unlock for disposal */
- DisposHandle(charh); /* Kill the chars */
- }
- else putln("No characters to copy darn it!");
- }
-
- /*
- * paste - Paste the resource from the scrap into the current WIND, if
- * and only if it is really text
- */
-
- void paste
- (
- void
- )
- {
- long
- #ifndef MPW
- GetScrap(), /* We must cast the Brother */
- #endif
- off, /* offset */
- length; /* the lenght of what is on the Scrap */
-
- /* Flush the buffer if we have echo */
-
- if ((screens[scrn].ftpstate == 0) && /* BYU */
- screens[scrn].echo && /* BYU */
- screens[scrn].kblen>0) { /* BYU */
- netwrite( screens[scrn].port, screens[scrn].kbbuf,
- screens[scrn].kblen); /* if full send buffer */
- screens[scrn].kblen=0;
- }
-
- if (GetScrap(0L, 'TEXT', &off)<=0L) /* If there are no TEXT res's */
- { putln("No text on scrap");
- return; /* then we can't paste it */
- }
-
- screens[scrn].outhand=NewHandle(0L); /* create a handle to put chars in */
-
- length= GetScrap( screens[scrn].outhand, 'TEXT',&off);
- /* Store the scrap into the handle */
- screens[scrn].outlen = length; /* Set the length */
- HLock(screens[scrn].outhand); /* Lock the Handle down for safety */
- screens[scrn].outptr=*screens[scrn].outhand; /* Set the pointer */
- if (screens[scrn].clientflags & PASTE_IN_PROGRESS) /* BYU 2.4.7 */
- SysBeep(4); /* BYU 2.4.7 */
- else { /* BYU 2.4.7 */
- screens[scrn].clientflags |= PASTE_IN_PROGRESS; /* BYU 2.4.7 */
- screens[scrn].incount = 0; /* BYU 2.4.7 */
- screens[scrn].outcount = 0; /* BYU 2.4.7 */
- pasteText(scrn); /* BYU 2.4.7 - routine to paste to net, w/echo if neccessary */
- }
- }
-
- void Macros
- (
- void
- )
- {
- DialogPtr dtemp;
- short dItem;
- int i;
- Rect dBox;
- Str255 temp;
- Handle MacString[10];
-
- SetCursor(normcurs);
-
- dtemp=GetNewDialog( MacroDLOG,(Ptr) 0L,(WindowPtr) -1L); /* Bring on the box */
- UItemAssign( dtemp, 23 , (int (*)()) OutlineItem);
-
- for (i=0; i<10; i++) {
- getmacro( i, &temp);
-
- GetDItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
- setitext( MacString[i], &temp );
- }
-
- dItem=0; /* initially no hits */
- while((dItem>2) || (dItem==0)) { /* While we are in the loop */
- ModalDialog((ModalFilterProcPtr) modalProc,&dItem); /* and do our duty to the box */
- if (dItem >2 && dItem <13) {
- i=dItem-3;
- getmacro( i, &temp);
-
- GetDItem( dtemp, i+13, &dItem, &MacString[i], &dBox);
- setitext( MacString[i], &temp ); /* Revert the mother */
- SelIText( dtemp, i+13, 0, 32767); /* And select it... */
- }
- }
-
- updateCursor(1);
-
- if (dItem==DLOGCancel) {
- DisposDialog( dtemp);
- return;
- }
-
- for (i=0; i<10; i++) {
- getitext( MacString[i], &temp);
- setmacro(i, &temp);
- }
-
- DisposDialog( dtemp);
- }
-
- void displayStatus
- (
- int n,
- int active
- )
- {
- DialogPtr dtemp;
- short item;
-
- SetCursor(normcurs);
-
- #ifndef MPW
- if (screens[n].corpse) {
- paramtext( screens[n].machine,"\Pis awaiting dismissal",0L,0L);
- }
- else {
- if (active <0) {
- paramtext( screens[n].machine,"\Pbeing looked up",0L,0L);
- }
- else {
- paramtext( screens[n].name,"\Pbeing opened", 0L, 0L);
- }
- }
- #else
- if (screens[n].corpse) {
- paramtext( screens[n].machine,"is awaiting dismissal",0L,0L);
- }
- else {
- if (active <0) {
- paramtext( screens[n].machine,"being looked up",0L,0L);
- }
- else {
- paramtext( screens[n].name,"being opened", 0L, 0L);
- }
- }
- #endif
-
- dtemp=GetNewDialog( StatusDLOG,(Ptr) 0L,(WindowPtr) -1L); /* Bring on the box */
- UItemAssign( dtemp, 3, (int (*)()) OutlineItem);
-
- item =DLOGCancel+1;
- while (item> DLOGCancel)
- ModalDialog((ModalFilterProcPtr) modalProc, &item);
-
- updateCursor(1);
-
- if (item ==DLOGCancel) {
- netclose(screens[n].port);
- destroyport( n);
- }
-
- DisposDialog( dtemp);
- }
-
- /*
- * changeport - handle the menu updates for changing from one port to another
- */
- void changeport
- (
- int oldprt,
- int newprt
- )
- {
-
- sprintf(tempspot,"oldscrn: %d, newscrn: %d",oldprt,newprt); putln(tempspot);
-
- if (screens[oldprt].active==0)
- CheckItem(myMenus[Conn], oldprt+3,FALSE); /* Adjust Conn menu */
- CheckItem(myMenus[Conn], newprt+3,TRUE);
-
- CheckItem(myMenus[Emul], EMbs,FALSE); /* Adjust BS */
- CheckItem(myMenus[Emul], EMdel,FALSE);
- CheckItem(myMenus[Emul], EMbs+screens[newprt].bsdel,TRUE); /* and DEL */
-
- if (screens[newprt].ESclear) /* BYU 2.4.8 */
- CheckItem(myMenus[Emul],EMclear,TRUE); /* BYU 2.4.8 */
- else /* BYU 2.4.8 */
- CheckItem(myMenus[Emul],EMclear,FALSE); /* BYU 2.4.8 */
-
- if (screens[newprt].ESscroll)
- CheckItem(myMenus[Emul],EMscroll,TRUE);
- else
- CheckItem(myMenus[Emul],EMscroll,FALSE);
-
- if (screens[newprt].echo) /* LOCAL ECHO */
- CheckItem(myMenus[Emul],EMecho,TRUE);
- else /* REMOTE ECHO */
- CheckItem(myMenus[Emul],EMecho,FALSE);
-
- if (screens[newprt].wrap) /* wrap on */
- CheckItem(myMenus[Emul],EMwrap,TRUE);
- else /* wrap off */
- CheckItem(myMenus[Emul],EMwrap,FALSE);
-
- if (VSiscapturing(screens[newprt].vs)) /* BYU 2.4.18 */
- CheckItem(myMenus[Emul], EMcapture,TRUE); /* BYU 2.4.18 */
- else /* BYU 2.4.18 */
- CheckItem(myMenus[Emul], EMcapture,FALSE); /* BYU 2.4.18 */
-
- scrn=newprt;
-
- SLIP_menus(); /* BYU 2.4.15 */
-
- CheckFonts();
- }
-
- /*
- * showNetNumbers - Show the current network numbers.
- */
- #ifndef MPW
- #define STR_BASE 1
- #else
- #define STR_BASE 0
- #endif
-
- void showNetNumbers
- (
- void
- )
- {
- char tmpout[30], /* IP Number */
- tmpout2[75]; /* Aux. Information */
- DialogPtr dtemp; /* dialog box pointer */
- int i, /* Looping Var */
- tmp[4]; /* Integer copy of IP Number */
-
- for(i=0; i<4; i++)
- tmp[i]=(int)myipnum[i]; /* Get integer numbers */
-
- if (dynamic) {
- if (EtherNet)
- sprintf(&tmpout[STR_BASE],"%d.%d.%d.%d [RARP]",tmp[0],tmp[1],tmp[2],tmp[3]);
- else
- sprintf(&tmpout[STR_BASE],"%d.%d.%d.%d [KIP]",tmp[0],tmp[1],tmp[2],tmp[3]);
- }
- else
- sprintf(&tmpout[STR_BASE],"%d.%d.%d.%d",tmp[0],tmp[1],tmp[2],tmp[3]);
- /* create Human-readable numbers */
-
- if (EtherNet==-99)
- sprintf( &tmpout2[STR_BASE], "Driver MacTCP");
- else
- if (EtherNet)
- sprintf( &tmpout2[STR_BASE], "EtherNet %x:%x:%x:%x:%x:%x\nSlot: %d\nSubnet Mask:%lx",
- (int)nnmyaddr[0], (int)nnmyaddr[1], (int)nnmyaddr[2],
- (int)nnmyaddr[3], (int)nnmyaddr[4], (int)nnmyaddr[5],
- EtherNet,mynetmask);
- else
- sprintf(&tmpout2[STR_BASE],"Appletalk Net: %d\nAppletalk Node: %d\nSubnet Mask:%lx",
- (int)nnmyaddr[0]*0x100+(int)nnmyaddr[1],
- (int)nnmyaddr[2], mynetmask);
-
- paramtext(0L,tmpout,0L,tmpout2); /* Put Parms in Dlog */
-
- dtemp=GetNewDialog(259,(Ptr) 0L,(WindowPtr) -1L); /* Get Dialog */
- DrawDialog(dtemp); /* Display Dialog */
-
- Wait4Mouse(); /* Wait for a click */
-
- DisposDialog(dtemp); /* kill it, kill it */
- }
-
- int PromptBadDynamic
- (
- void
- )
- {
- DialogPtr dtemp;
- short item;
-
- #ifndef MPW
- paramtext(0L,"\Pobtain dynamic",0L,0L);
- if (EtherNet) {
- paramtext( "\PRARP",0L,0L,0L);
- }
- else {
- paramtext( "\PKIP",0L,0L,0L);
- if (!dynamic)
- paramtext(0L,"\Pregister static",0L,0L);
- }
- #else
- paramtext(0L,"obtain dynamic",0L,0L);
- if (EtherNet) {
- paramtext( "RARP",0L,0L,0L);
- }
- else {
- paramtext( "KIP",0L,0L,0L);
- if (!dynamic)
- paramtext(0L,"register static",0L,0L);
- }
- #endif MPW
-
- dtemp=GetNewDialog( BadDynDLOG,(Ptr) 0L,(WindowPtr) -1L); /* Bring on the box */
- UItemAssign( dtemp, 3, (int (*)()) OutlineItem);
-
- item =DLOGCancel+1;
- while (item> DLOGCancel)
- if (item ==5) {
- DisposDialog(dtemp);
- return(-1);
- }
- else ModalDialog((ModalFilterProcPtr) modalProc, &item);
-
- DisposDialog( dtemp);
-
- if (item ==DLOGCancel) {
- return(0);
- }
-
- return(1);
- }
-
- void reconfigNetwork
- (
- int warning
- )
- {
- int again=1;
- int error=1;
-
- if (warning)
- again = PromptBadDynamic();
-
- if (again<0) { /* REMOVE THIS SOON! */
- error=0;
- again=0;
- }
- while (again) {
- again=0; error=0;
- if ( PromptIP( dynamic)) {
- if (!EtherNet) { /* BYU 2.4.12 - was KIP */
- DynamIP(myipnum); /* KIP Dynamic IP Numbers */
- error = RegIP(myipnum);
- }
- else {
- netsetip("RARP"); /* RARP Dynamic IP Numbers -ET */
- error = netgetrarp();
- netgetip(myipnum);
- }
-
- if (!(myipnum[0] & 0x80))
- defmask=0xff000000; /* Class A */
- else if ( (myipnum[0] & 0xC0 )==0x80)
- defmask=0xffff0000; /* Class B */
- else if ( (myipnum[0] & 0xC0 )==0xC0)
- defmask=0xffffff00; /* Class C */
- if (!cmask) mynetmask=defmask;
- dynamic=1;
- }
- else {
- dynamic =0;
- error = RegIP(myipnum);
- }
- if (error)
- again=PromptBadDynamic();
- }
-
- if (error)
- quit();
- else {
- setnetconfigs( myipnum, &mynetmask); /* Assign the new mask and IP numbers */
- netarpme(myipnum); /* Anyone Else using my IP Number? */
-
- Ssetgates(); /* finishes IP inits */
- }
- }
-
- void LinesPlease
- (
- int scrn
- )
- {
- DialogPtr dtemp;
- Rect dBox;
- short dItem;
- Handle lines;
- char strlines[50];
- int numlines,notgood;
-
-
- dtemp=GetNewDialog( LinesDLOG,(Ptr) 0L,(WindowPtr) -1L); /* Bring on the box */
- UItemAssign( dtemp, 3, (int (*)()) OutlineItem); /* Default is #3 [OK] */
-
- SetCursor(normcurs);
-
- notgood = 1;
- sprintf( strlines, "%d", VSgetlines( screens[scrn].vs) );
- GetDItem( dtemp, LinesNumber, &dItem, &lines, &dBox); /* Install the default host */
-
- while (notgood) {
- notgood = 0; /* Default to good */
- setitext( lines , strlines);
- SelIText( dtemp, LinesNumber, 0, 32767); /* And select it... */
-
- dItem=0; /* initially no hits */
- while((dItem>3) || (dItem==0)) /* While we are in the loop */
- ModalDialog((ModalFilterProcPtr) modalProc,&dItem); /* and do our duty to the box */
-
- if (dItem==DLOGCancel) {
- DisposDialog( dtemp);
- return;
- }
-
- getitext( lines, strlines); /* Get the string */
- sscanf( strlines, "%d", &numlines); /* Get the number */
-
- if (numlines <10) {
- numlines = 10;
- SysBeep(5);
- notgood=1;
- } else if (numlines > 200) {
- numlines = 200;
- SysBeep(5);
- notgood=1;
- }
- }
- DisposDialog( dtemp);
-
- VSsetlines( screens[scrn].vs, numlines);
- RSsize( screens[scrn].wind, NULL, 0);
-
-
- if (screens[scrn].naws) /* NCSA 2.5: send size of window to server */
- { /* NCSA 2.5 */
- char parsedat[20]; /* NCSA 2.5 */
- netpush (screens[scrn].port); /* NCSA 2.5 */
- /* NCSA 2.5 */
- /* NCSA 2.5: syntax for command is: IAC SB NAWS widthHI widthLO heightHI heightLO IAC SE */
- /* NCSA 2.5 */
- sprintf(parsedat,"%c%c%c%c%c%c%c%c%c",255,250,31,(char)0 /* NCSA 2.5 */
- ,(char)screens[scrn].width,(char)0,numlines,255,240); /* NCSA 2.5 */
- netwrite(screens[scrn].port,parsedat,9); /* NCSA 2.5: send data */
- } /* NCSA 2.5 */
-
- updateCursor(1);
- }
-
- /*******************************************************************/
- /* setupkeys
- * Prompt the user for which keys to use for kill, stop and start.
- */
- #define killbox 5
- #define stopbox 6
- #define startbox 7
-
- void setupkeys
- (
- void
- )
- {
- DialogPtr dtemp;
- Rect dBox;
- short dItem,kItem,sItem,eItem;
- Handle kbox,sbox,ebox;
-
- dtemp=GetNewDialog( SetupDLOG,(Ptr) 0L,(WindowPtr) -1L); /* Bring on the box */
- UItemAssign( dtemp, 3, (int (*)()) OutlineItem); /* Default is #3 [OK] */
-
- SetCursor(normcurs);
-
- GetDItem( dtemp, killbox, &kItem, &kbox, &dBox);
- GetDItem( dtemp, stopbox, &eItem, &ebox, &dBox);
- GetDItem( dtemp, startbox, &sItem, &sbox, &dBox);
-
- *tempspot = 0;
- if (screens[scrn].TELstop > 0) {
- sprintf(tempspot,"^%c",screens[scrn].TELstop^64);
- setitext( ebox , tempspot);
- SelIText( dtemp, stopbox, 0, 32767);
- }
- if (screens[scrn].TELgo > 0) {
- sprintf(tempspot,"^%c",screens[scrn].TELgo^64);
- setitext( sbox , tempspot);
- SelIText( dtemp, startbox, 0, 32767);
- }
- if (screens[scrn].TELip > 0) {
- sprintf(tempspot,"^%c",screens[scrn].TELip^64);
- setitext( kbox , tempspot);
- SelIText( dtemp, killbox, 0, 32767);
- }
-
- dItem=0; /* initially no hits */
- while((dItem>3) || (dItem==0)) { /* While we are in the loop */
- ModalDialog((ModalFilterProcPtr) modalProc,&dItem); /* and do our duty to the box */
-
- /*
- * intermediate check. If they hit a key, put its number in the box.
- */
- getitext( kbox, tempspot); /* Get the string */
- if (*tempspot < 32 && *tempspot > 0) {
- sprintf(tempspot,"^%c",*tempspot^64);
- setitext( kbox , tempspot);
- SelIText( dtemp, killbox, 0, 32767 );
- }
- getitext( ebox, tempspot); /* Get the string */
- if (*tempspot < 32 && *tempspot > 0) {
- sprintf(tempspot,"^%c",*tempspot^64);
- setitext( ebox , tempspot);
- SelIText( dtemp, stopbox, 0, 32767);
- }
- getitext( sbox, tempspot); /* Get the string */
- if (*tempspot < 32 && *tempspot > 0) {
- sprintf(tempspot,"^%c",*tempspot^64);
- setitext( sbox , tempspot);
- SelIText( dtemp, startbox, 0, 32767);
- }
-
- }
-
-
- if (dItem==DLOGCancel) {
- DisposDialog( dtemp);
- return;
- }
-
- getitext( kbox, tempspot); /* Get the string */
- if (*tempspot != '^')
- screens[scrn].TELip = -1;
- else
- screens[scrn].TELip = toupper(*(tempspot+1)) ^ 64;
-
- getitext( ebox, tempspot); /* Get the string */
- if (*tempspot != '^')
- screens[scrn].TELstop = -1;
- else
- screens[scrn].TELstop = toupper(*(tempspot+1)) ^ 64;
-
- getitext( sbox, tempspot); /* Get the string */
- if (*tempspot != '^')
- screens[scrn].TELgo = -1;
- else
- screens[scrn].TELgo = toupper(*(tempspot+1)) ^ 64;
-
-
- DisposDialog( dtemp);
-
- updateCursor(1);
- }
-
- /*
- * . - preform a command denoted by the arguments.
- * mResult - the result of the menu event
- * modifiers- modifiers from the menu event
- */
-
- void docommand
- (
- long mResult,
- short modifiers
- )
- {
- register int i;
- int theItem, theMenu;
-
- theMenu = mResult >> 16;
- theItem = mResult & 0xffff;
- switch(theMenu) {
- case appleMenu:
- if (theItem==1) /* About Dialog */
- applAbout();
- else
- {
- Str255
- name;
- GetItem(myMenus[0], theItem, name); /* Desk accessory */
- OpenDeskAcc(name);
- }
- break;
-
- case fileMenu:
- switch(theItem) {
-
- case FLopen:
- setupport(NOFTP); /* Open a connection */
- break;
-
- case FLclose:
- if ( numwindows<1 ) break; /* Close a connection */
- if ( screens[scrn].corpse) {
- netclose( screens[scrn].port);
- destroyport( scrn);
- }
- else {
- if ( !ReallyClose( scrn) ) break;
- netclose(screens[scrn].port);
- removeport( scrn);
- }
- if (numwindows <1)
- {
- DisableItem( myMenus[Conn],0);
- DisableItem(myMenus[Conn],COnext);
- DrawMenuBar();
- }
- break;
-
- case FLload: /* Load a set */
- LoadCONF();
- break;
- case FLsave: /* Save a set */
- if (numwindows<1) break;
- SaveCONF();
- break;
- case FLftp:
- ftpavail=!ftpavail; /* Toggle FTP on/off */
- if (ftpavail) {
- CheckItem(myMenus[Fil], FLftp,TRUE);
- Sftpmode(1);
- }
- else {
- CheckItem(myMenus[Fil], FLftp,FALSE);
- Sftpmode(0);
- }
- break;
-
- case FLbin: /* Toggle MacBinary on/off */
- MacBinary = !MacBinary;
- if (MacBinary) {
- CheckItem(myMenus[Fil], FLbin,TRUE);
- }
- else {
- CheckItem(myMenus[Fil], FLbin,FALSE);
- }
- break;
-
- case FLlog: /* Toggle FTP window on/off*/
- ftplogon=!ftplogon;
- if(ftplogon) {
- CheckItem(myMenus[Fil],FLlog,TRUE);
- RSshow(ftplog.vs);
- SelectWindow(ftplog.wind);
- }
- else {
- CheckItem(myMenus[Fil],FLlog,FALSE);
- RShide(ftplog.vs);
- }
- break;
-
- case FLdir: /* Set the working dir. */
- wdset();
- break;
-
- case FLprint: /* Print Selection (or gr) */
- if (prRecHdl==0L) { /* Make sure print is inited */
- PrOpen();
- prRecHdl=(THPrint)NewHandle((long)sizeof(TPrint));
- PrintDefault(prRecHdl);
- }
- i=RGgetdnum(FrontWindow());
- if (i>-1)
- printGraph( i); /* Print Graphics */
- else
- if ( (i=RSfindvwind(FrontWindow())) >-1 ) {
- Str255 Title;
-
- getwtitle( FrontWindow(), &Title);
- printText(i, (Str255 *) &Title,scrn); /* Print Text selection */
- }
- break;
-
- case FLpset: /* Set up for printer */
- if (prRecHdl==0L) { /* make sure print is inited */
- PrOpen();
- prRecHdl=(THPrint)NewHandle((long)sizeof(TPrint));
- PrintDefault(prRecHdl);
- }
- PrStlDialog(prRecHdl); /* Present the style dlog*/
- break;
-
- case FLquit:
- if (numwindows>0)
- {
- if (ReallyQuit())
- {
- serial_shut(); /* BYU serial - close serial port */
- for (i = numwindows - 1; i >= 0; i--)
- {
- netclose(screens[i].port);
- destroyport(i);
- } /* for */
- }
- else
- break;
- } /* if */
- quit(); /* Guess what this does */
- break;
-
- }
- break;
-
- case editMenu:
- if (!SystemEdit(theItem-1)) { /* Is this mine? */
- switch(theItem) {
- case EDcopy: /* Copy */
- i = MacRGfindwind(FrontWindow()); /* is ICR window? */
- if (i >= 0)
- MacRGcopy(FrontWindow()); /* copy the ICR window */
- else {
- i=RGgetdnum(FrontWindow());
- if (i>-1) /* Copy Graphics */
- copyGraph( i);
- else /* Copy Text */
- if ( (i=RSfindvwind(FrontWindow())) >-1)
- copyText( i);
- }
- break;
-
- case EDcopyt: /* Copy Table */
- /*
- * tech note #180 trick to get MultiFinder to pay attention
- */
- if (!SystemEdit(EDcopy-1)) { /* tell it we did a copy */
- i=RGgetdnum(FrontWindow());
- if (i>-1) /* Copy Graphics */
- copyGraph( i);
- else /* Copy Text */
- if ( (i=RSfindvwind(FrontWindow())) >-1)
- copyTable( i);
- }
- break;
-
- case EDpaste: /* Paste */
- if (numwindows<1)
- break;
- else paste(); /* Paste if there is a wind to do to*/
- break;
- case EDmacros: /* Set them Macros */
- Macros();
- break;
- case EDprefs: /* You know what I like! */
- PromptPrefs();
- break;
- default:
- break;
- }
- }
- break;
-
- case connMenu:
- if (theItem==1)
- {
- if (numwindows >1)
- {
- SendBehind( FrontWindow(), 0L);
- if (FrontWindow() == console.wind || FrontWindow() == ftplog.wind)
- SendBehind( FrontWindow(), 0L);
- }
- break;
- }
-
- else
- {
- if ((theItem-2)>(numwindows+1)) break; /* rotten danish */
- if (screens[ --theItem-2].active!=0)
- {
- displayStatus(theItem-2, screens[theItem-1].active); /* Tell them about it..... */
- break;
- }
- else
- {
- HiliteWindow(screens[scrn].wind, FALSE);
- changeport(scrn,(theItem-2));
- if (!(modifiers & optionKey)) SelectWindow(screens[scrn].wind);
- else HiliteWindow(screens[scrn].wind, TRUE);
- }
- }
- break;
-
- case netMenu:
- switch(theItem) {
- case NEftp: /* Send FTP command */
- case NEip: /* Send IP Number */
- if (numwindows<1) break;
- { char tmpout[30]; /* Basically the same except for */
- int tmp[4]; /* The ftp -n phrase in NEftp */
-
- if (screens[scrn].echo && (screens[scrn].kblen>0)) {
- netwrite( screens[scrn].port, screens[scrn].kbbuf,
- screens[scrn].kblen);/* if not empty send buffer */
- screens[scrn].kblen=0;
- }
- if (screens[scrn].connectionType == 1) /* BYU 2.4.15 */
- for(i=0; i<4; i++) tmp[i]=(int)SLIP_ip_number[i]; /* BYU 2.4.15 */
- else /* BYU 2.4.15 */
- for(i=0; i<4; i++) tmp[i]=(int)myipnum[i]; /* BYU 2.4.15 */
- if (theItem == NEftp) {
- if ((modifiers & shiftKey) != 0) /* BYU mod */
- sprintf(tmpout,"ftp %d.%d.%d.%d\015\012",tmp[0],tmp[1],tmp[2],tmp[3]); /* BYU mod */
- else /* BYU mod */
- sprintf(tmpout,"ftp -n %d.%d.%d.%d\015\012",tmp[0],tmp[1],tmp[2],tmp[3]); /* BYU mod */
- } /* BYU mod */
- else
- sprintf(tmpout,"%d.%d.%d.%d",tmp[0],tmp[1],tmp[2],tmp[3]);
- netwrite(screens[scrn].port,tmpout,strlen(tmpout));
- if (screens[scrn].echo)
- VSwrite(screens[scrn].vs,tmpout, strlen(tmpout));
- }
- break;
-
- case NEayt: /* Send "Are You There?"*/
- if (numwindows<1) break;
- netpush(screens[scrn].port);
- netwrite(screens[scrn].port, "\377\366",2);
- break;
-
- case NEao: /* Send "Abort Output"*/
- if (numwindows<1) break;
- netpush(screens[scrn].port);
- netwrite(screens[scrn].port, "\377\365",2);
- screens[ scrn].timing = 1; /* set emulate to TMwait */
- netwrite(screens[scrn].port, "\377\375\006",3); /* send TM */
- break;
-
- case NEinter: /* Send "Interrupt Process"*/
- if (numwindows<1) break;
- netpush(screens[scrn].port);
- netwrite(screens[scrn].port, "\377\364",2);
- screens[ scrn].timing = 1; /* set emulate to TMwait */
- netwrite(screens[scrn].port, "\377\375\006",3); /* send TM */
- break;
-
- case NEec: /* Send "Erase Character"*/
- if (numwindows<1) break;
- netpush(screens[scrn].port);
- netwrite(screens[scrn].port, "\377\367",2);
- break;
-
- case NEel: /* Send "Erase Line"*/
- if (numwindows<1) break;
- netpush(screens[scrn].port);
- netwrite(screens[scrn].port, "\377\370",2);
- break;
-
- case NEscroll: /* Suspend Network */
- ScrlLock=!ScrlLock;
- if (ScrlLock)
- CheckItem(myMenus[Net], NEscroll,TRUE);
- else
- CheckItem(myMenus[Net], NEscroll,FALSE);
- break;
-
- case NEnet: /* Show Network Numbers */
- showNetNumbers();
- break;
-
- case NEconfig:
- if (userlevel != 0) break;
- if (EtherNet == -99) /* drivers are alive version */
- driverconf(); /* just configure default host */
- else {
- if (numwindows > 0) break;
- reconfigNetwork(0);
- }
- break;
-
- case NEserial: /* BYU serial */
- Setmodem(); /* BYU serial */
- break; /* BYU serial */
-
- case NEalias: /* NCSA */
- DoAlias(); /* NCSA */
- break; /* NCSA */
-
- default:
- break;
- }
- break;
-
- case termMenu:
- switch(theItem) {
-
- case EMbs: /* Backspace for backspace */
- if (numwindows<1) break;
- CheckItem(myMenus[3], EMbs+screens[scrn].bsdel,FALSE);
- screens[scrn].bsdel=0;
- CheckItem(myMenus[3], EMbs+screens[scrn].bsdel,TRUE);
- break;
-
- case EMdel: /* Delete for backspace */
- if (numwindows<1) break;
- CheckItem(myMenus[3], EMbs+screens[scrn].bsdel,FALSE);
- screens[scrn].bsdel=1;
- CheckItem(myMenus[3], EMbs+screens[scrn].bsdel,TRUE);
- break;
-
- case EMecho: /* Toggle Local Echo (if poss.) */
- if (numwindows < 1) break;
- if (screens[scrn].echo && (screens[scrn].kblen>0)) {
- netwrite( screens[scrn].port, screens[scrn].kbbuf,
- screens[scrn].kblen); /* if not empty send buffer */
- screens[scrn].kblen=0;
- }
- screens[scrn].echo= !screens[scrn].echo; /* toggle */
- if (screens[scrn].echo) { /* LOCAL ECHO */
- netwrite(screens[scrn].port,"\377\376\001",3);
- CheckItem(myMenus[3],EMecho,TRUE);
- }
- else { /* REMOTE ECHO */
- netwrite(screens[scrn].port,"\377\375\001",3);
- CheckItem(myMenus[3],EMecho,FALSE);
- }
- break;
-
- case EMwrap: /* wrap mode */
- if (numwindows < 1) break;
- if (!screens[scrn].wrap) { /* is off, turn on */
- screens[scrn].wrap = 1;
- CheckItem( myMenus[3],EMwrap, TRUE);
- VSwrite(screens[scrn].vs, "\033[?7h",5); /* kick emulator */
- }
- else {
- screens[scrn].wrap = 0;
- CheckItem( myMenus[3],EMwrap, FALSE);
- VSwrite(screens[scrn].vs, "\033[?7l",5);
- }
- break;
-
- case EMscroll: /* Scrollback on CLS */
- if (numwindows<1) break;
- screens[scrn].ESscroll = !screens[scrn].ESscroll;
- VSscrolcontrol( screens[scrn].vs, -1, screens[scrn].ESscroll);
- if (screens[scrn].ESscroll)
- CheckItem(myMenus[3],EMscroll, TRUE);
- else
- CheckItem(myMenus[3],EMscroll, FALSE);
- break;
-
- case EMpage: /* TEK page command */
- if (numwindows<1) break;
- parse( &screens[scrn], "\033\014",2);
- break;
-
- case EMclear: /* BYU 2.4.8 - Clear on TEK page */
- if (numwindows<1) break; /* BYU 2.4.8 */
- screens[scrn].ESclear = !screens[scrn].ESclear; /* BYU 2.4.8 */
- if (screens[scrn].ESclear) /* BYU 2.4.8 */
- CheckItem(myMenus[3],EMclear, TRUE); /* BYU 2.4.8 */
- else /* BYU 2.4.8 */
- CheckItem(myMenus[3],EMclear, FALSE); /* BYU 2.4.8 */
- break; /* BYU 2.4.8 */
-
- case EMlines: /* set the # of lines */
- if (numwindows<1) break;
- LinesPlease( scrn);
- break;
-
- case EMreset: /* Reset Screen */
- if (numwindows<1) break;
- VSreset(screens[scrn].vs); /* Reset it */
- screens[scrn].timing=0;
- screens[scrn].wrap = 0; /* turns wrap off */
- CheckItem( myMenus[3],EMwrap, FALSE);
- break;
- case EMjump: /* Jump Scroll */
- if (numwindows<1) break;
- FlushNetwork(scrn); /* Flush it */
- break;
-
- case EMsetup: /* need dialog to enter new key values */
- setupkeys();
- break;
-
- case EMcolor: /* Set color */
- if (numwindows<1) break;
- if (HasColor)
- RScprompt(screens[scrn].vs, (int (*)()) modalProc); /* Color it */
- break;
-
- case EMslip: /* BYU 2.4.15 - Switch to SLIP */
- if (numwindows<1) /* BYU 2.4.15 */
- break; /* BYU 2.4.15 */
- switchtoslip(screens[scrn].port); /* BYU 2.4.15 */
- break; /* BYU 2.4.15 */
-
- case EMserial: /* BYU 2.4.15 - Switch to Serial */
- if (!slip_connection) /* BYU 2.4.16 */
- break; /* BYU 2.4.15 */
- slip_connection = 0; /* BYU 2.4.15 */
- serial_scrn = -1; /* BYU 2.4.15 */
- SLIP_menus(); /* BYU 2.4.16 */
- break; /* BYU 2.4.15 */
-
- case EMcapture: /* BYU 2.4.18 - Capture session to file */
- if (VSiscapturing(screens[scrn].vs)) { /* BYU 2.4.18 */
- CloseCaptureFile(screens[scrn].vs); /* BYU 2.4.18 */
- } else { /* BYU 2.4.18 */
- if(!VSopencapture(scrn, screens[scrn].vs)) /* BYU 2.4.18 */
- CheckItem(myMenus[Emul], EMcapture,TRUE); /* BYU 2.4.18 */
- } /* BYU 2.4.18 */
-
- break; /* BYU 2.4.18 */
-
- #ifdef NOTANYMORE
- case EMcommand: /* Switch menus */
- whichMenus=!whichMenus;
- switchMenus(whichMenus);
- break;
- #endif NOTANYMORE
- default:
- break;
- }
- break;
- case fontMenu:
- if (numwindows>0) {
- RSchangefont( screens[scrn].vs, FontNumber[theItem], 0, 1);
- CheckFonts();
- }
- break;
- case sizeMenu:
- if (numwindows>0) {
- RSchangefont( screens[scrn].vs, -1, FontSize[theItem], 1);
- CheckFonts();
- }
- break;
- default:
- break;
-
- }
- HiliteMenu(0);
- } /* docommand */
-
- /*
- * portsOpen() - Count the number of ports open. Returns 3 different answers
- * 0= no ports at all, 1= at least active, -1= ports/none active.
- */
-
- int portsOpen()
- {
- int pnum;
-
- pnum=numwindows-1;
- if (pnum<0) return(0);
- while (pnum>=0)
- if (!screens[pnum--].active && !screens[pnum+1].corpse) return(1);
- return(-1);
- }
-
- /*
- * extractmenu - remove a connection from the menu.
- */
-
- void extractmenu
- (
- int pnum
- )
- {
- DelMenuItem(myMenus[Conn],pnum+3);
-
- AdjustMenus();
- }
-
- /*
- * addinmenu - add a connection's name to the menu in position pnum. (name is
- * an str255 pointed at by temps).
- */
-
- void addinmenu
- (
- int pnum,
- Str255 *temps,
- char mark
- )
- {
-
- insmenuitem(myMenus[Conn], (char *) temps, pnum+2); /* add string to connections menu */
-
- SetItemMark( myMenus[Conn], pnum+3, mark); /* check this with the appropriate mark */
- AdjustMenus();
- }
-
- /*
- * opnport(scrn) - Sets the item mark for <scrn> to opening connection
- */
-
- void opnport
- (
- int scrn
- )
- {
- unsigned char c=0xa5;
-
- SetItemMark( myMenus[Conn],scrn+3, c );
- }
-
- /*
- * liveport(scrn) - Sets the item mark for <scrn> to opened connection
- */
-
- void liveport
- (
- int scrn
- )
- {
- unsigned char c=0x00;
-
- SetItemMark( myMenus[Conn],scrn+3, c);
- AdjustMenus();
- }
-
- /*
- * RGtoPICT(i) - Converts the data in TEK window <i> to PICT format.
- * returns the handle to the picture.
- */
-
- PicHandle RGtoPICT(i)
- int i;
- {
- int j;
- PicHandle tpic;
- Rect trect;
-
- SetRect(&trect,0,0,384,384);
- j=VGnewwin(3,VGgetVS(i)); /* NCSA 2.5: get the right VS */
- RGMPsize( &trect );
- VGzcpy( i, j); /* Love dat zm factr */
- tpic=OpenPicture(&trect);
- ClipRect(&trect);
-
- VGredraw(i,j);
- ClosePicture();
- VGclose(j);
-
- return(tpic);
- }
-
- /*
- * printsleep() - Provide the network keep alive while we are in print
- * mode. Also set the abort flag if necessary.
- */
- void printsleep()
- {
- Stask(); /* act like the postman */
- if (userabort()) (*prRecHdl)->prJob.fFromUsr=TRUE;
- }
-
-
-
-
-
- /*------------------------------------------------------------------*/
- /* Alias code */
- /* NCSA, April 1992 */
- /*------------------------------------------------------------------*/
-
-
-
- /* Find out which item is selected */
- short GetSelectedAlias(ListHandle hList,int theNum)
- {
- short i;
- Point theCell;
-
- for (i=0;i < theNum;i++)
- {
- SetPt(&theCell,0,i);
- if (LGetSelect(0,&theCell,hList))
- return i;
- }
- return 0;
- }
-
-
-
-
- /* Get the list of aliases from the resource file "NCSA Prefs."
- If there is no such list yet, then make one from scratch */
- AliasRez **GetAlias()
- {
- AliasRez **theResource;
- AliasRez *pAliasrez, **hAliasrez;
- int terr;
-
- theResource = (AliasRez **)GetResource('alia',1000);
- if (theResource !=0L)
- return theResource; /* send it */
-
- else /* Make a new one from scratch */
- {
-
- hAliasrez = (AliasRez **)NewHandle(sizeof(AliasRez));
- HLock ((Handle)hAliasrez);
-
- pAliasrez = *hAliasrez;
- pAliasrez->number =0;
- pAliasrez->aliases[0].name[0] = 0; /* no data for us */
- pAliasrez->aliases[0].port = 0;
- pAliasrez->aliases[0].alias[0] = 0;
- HUnlock((Handle)hAliasrez);
-
-
- /* add this to the resource file, and check for some strange errors */
-
- addresource((Handle)hAliasrez,'alia',1000,"aliases"); /* NCSA 2.5 */
- if ((terr=ResError())!=0) {
- putln("Error in addresource");
- }
- else
- {
- ChangedResource((Handle)hAliasrez);
- UpdateResFile(HomeResFile((Handle) hAliasrez));
- }
- return hAliasrez;
- }
- }
-
-
- /* called when a record needs to be deleted, and all the records
- after it have to be bumped up a slot... */
- void DeleteAlias (short theNum, AliasRez **hAlias)
- {
- short i;
- AliasRez *pResource;
-
- pResource = *hAlias; /* shut up, Tim */
-
- pResource->number--;
- for (i=theNum;i < pResource->number; i++)
- {
- strcpy(pResource->aliases[i].name,pResource->aliases[i+1].name);
- strcpy(pResource->aliases[i].alias, pResource->aliases[i+1].alias);
- pResource->aliases[i].port = pResource->aliases[i+1].port;
- }
- }
-
-
-
- /* this is the main controlling routine. Called from DoCommand each
- time the user selects the Alias... menu item. Get the data from the
- resource file, and allow the user to add and remove items, in a modal
- dialog setting. At the end, save all relevant changes back to the
- resource file, and then relax until next time*/
- void DoAlias
- (
- void
- )
- {
- DialogPtr dtemp;
- short dItem;
- Rect dBox;
- Handle hHost,hPort,hAlias,hList; /* dialog control handles */
- AliasRez **theResource,*pResource; /* alias resource data */
- short oldSize,numRecords;
- char junk[64];
- ListHandle theList; /* our List */
- Rect listBounds;
- Point cellSize,theCell;
- GrafPtr savePort; /* Dont hammer the port! */
- short i;
-
- theResource = GetAlias(); /* get the resource */
- dtemp=GetNewDialog( AliasDLOG, (Ptr) 0L, (WindowPtr) -1L); /* Bring on the box */
- GetPort (&savePort);
- SetPort((GrafPtr)dtemp);
- UItemAssign( dtemp, kAliasOutline , (int (*)()) OutlineItem);
-
-
- /* lets get some initial data */
- GetDItem( dtemp, kAliasHostItem, &dItem, &hHost, &dBox);
- GetDItem( dtemp, kAliasPortItem, &dItem, &hPort, &dBox);
- GetDItem( dtemp, kAliasAliasItem, &dItem, &hAlias, &dBox);
- GetDItem( dtemp, kAliasList, &dItem, &hList, &dBox);
-
- SetRect(&listBounds,0,0,1,0);
- SetPt(&cellSize,150,20);
-
- FrameRect(&dBox);
- InsetRect(&dBox,1,1);
- dBox.right -= 16;
-
- theList = LNew(&dBox,&listBounds,cellSize,0,(WindowPtr)dtemp,
- 1,0,0,1); /* make the new list from scratch */
-
- HLock((Handle)theResource);
- pResource = *theResource;
-
- /* add all of the saved aliases to the list */
-
- for (i=0;i< (**theResource).number;i++)
- {
- LAddRow(1,0,theList);
- SetPt(&theCell,0,0);
- LSetCell(pResource->aliases[i].alias,strlen(pResource->aliases[i].alias),
- theCell,theList);
- }
- HUnlock((Handle)theResource);
- LSetSelect(1,theCell,theList);
-
-
- SelIText( dtemp, kAliasHostItem, 0, 32767);
- HLock((Handle)theResource);
- pResource = *theResource;
-
-
- /* this is the main dialog routine. Keep chugging away until the user
- hits OK, or Cancel. Make sure the list is updated each time the
- user hits inside our list rect */
-
- dItem=0; /* initially no hits */
- while((dItem>2 ) || (dItem==0)) { /* While we are in the loop */
- ModalDialog((ModalFilterProcPtr) modalProc,&dItem); /* and do our duty to the box */
-
- if (dItem == kAliasAdd)
- {
- oldSize = GetHandleSize((Handle)theResource);
- SetHandleSize((Handle)theResource,oldSize + sizeof(AliasRecord));
- numRecords = pResource->number++;
- getitext(hHost,pResource->aliases[numRecords].name); /* NCSA 2.5 */
- getitext(hAlias,pResource->aliases[numRecords].alias); /* NCSA 2.5 */
- getitext(hPort,junk); /* NCSA 2.5 */
- sscanf(junk,"%d",&pResource->aliases[numRecords].port);
- theCell.h=0;
- theCell.v = GetSelectedAlias (theList, numRecords-1);
- LSetSelect(0,theCell, theList);
- SetPt(&theCell,0,0);
-
- LAddRow(1,0,theList);
- LSetCell(pResource->aliases[numRecords].alias,strlen(pResource->aliases[numRecords].alias),
- theCell,theList);
- LSetSelect(1,theCell,theList);
- }
-
- if (dItem == kAliasRemove )
- {
- numRecords = pResource->number;
- theCell.v = GetSelectedAlias (theList, numRecords );
- LDelRow(1,theCell.v,theList);
- DeleteAlias(numRecords - theCell.v -1,theResource);
- SetPt(&theCell,0,0);
- LSetSelect(1,theCell, theList);
- oldSize = GetHandleSize((Handle)theResource);
- SetHandleSize((Handle)theResource,oldSize - sizeof(AliasRecord));
- }
-
- if (dItem == kAliasList)
- {
- Point theMouse;
-
- GetMouse(&theMouse);
- LClick(theMouse,kListMods,theList);
- theCell = LLastClick(theList);
- }
- }
-
-
- HUnlock((Handle)theResource); /* Now you can munge the heap */
-
- if (dItem==kAliasCancel) /* go away without a trace */
- {
- SetPort(savePort);
- LDispose(theList);
- DisposDialog( dtemp);
- ReleaseResource ((Handle)theResource);
- return;
- }
-
-
- if (dItem == kAliasOK) /* save the changes for next time */
- {
- ChangedResource((Handle)theResource);
- UpdateResFile(HomeResFile((Handle) theResource));
- }
-
-
- SetPort(savePort);
- LDispose(theList);
- DisposDialog( dtemp);
- ReleaseResource((Handle)theResource);
- }
-
-
-
-
-
- /* given an Alias Name, get all of the data about the host and port.
- This is called by SetUpPort, and is called whenever the user tries
- to open any connection. Just check to see if the name is an alias. */
-
- int GetDataFromAlias(char *theAlias, AliasRecord *theRecord)
- {
- AliasRez **hAlias, *pAlias;
- short i;
- short found;
-
-
- hAlias = (AliasRez **)GetResource('alia',1000);
- if (hAlias == 0L)
- return -1;
-
- HLock((Handle)hAlias);
- pAlias = *hAlias;
-
- found = 0;
- for (i=0;i < pAlias->number; i++) /* found it!! */
- if (strcmp(theAlias,pAlias->aliases[i].alias) ==0 )
- {
- strcpy(theRecord->name,pAlias->aliases[i].name);
- strcpy(theRecord->alias,pAlias->aliases[i].alias);
- theRecord->port = pAlias->aliases[i].port;
- found =1;
- }
-
- HUnlock((Handle)hAlias);
- ReleaseResource((Handle)hAlias);
- return found;
- }
-